playMaker

Author Topic: spawning 10 enemy prefabs and assigning a unique health to each one?  (Read 2878 times)

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
So I'm having a problem where all my enemies share the same health.

I have a prefab called zombie. When the game first launches a global variable called zombie_health is set to 100.

When a zombie spawns, and i shoot at it, the game will retract -25 from the zombie_health. When zombie_health reaches 0, the zombie will destroy itself

When i spawn more than one zombie, they obviously share this one variable and thus all have the same health and will all die when health reaches 0 - also, shooting any of the zombies will retract health from the variable, so i can have 4 zombies and shoot each of them once and they will all die

I have been messing around with possible solutions for a couple of hours but can't find one that works..

Any of you geniouses have any idea as to how i can spawn a zombie and assign to it a unique health bar, and track damage to that specific zombie?

Right now the tracker is a ray-cast from the bullet that saves object hit as a variable. It then compares the variable with the word "zombie", so it checks if target hit = zombie and if it is, it will do 25 damage to the zombie_health variable

Any help is greatly appriciated.

__________________________________________________________________________________________

A few hours later now, and i've tried giving the zombie prefab a local variable called "my health" and then when 10 zombies are in the game, the bullet would save "object hit" in a variable, which would then trigger an event to that specific zombie to fire it's event "take damage".. But I can't make a send event like that because i can't reference the specific zombie - the "target hit" variable doesn't work =(

There must be a smart solution for this - Am I just too narrow-minded to see it right now?

Any help appriciated - this is doing my head in =(
« Last Edit: November 26, 2012, 02:54:36 PM by KozTheBoss »
Remember, you don't fail unless you give up trying to succeed!

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: spawning 10 enemy prefabs and assigning a unique health to each one?
« Reply #1 on: November 26, 2012, 03:34:16 PM »
Bump, still hopeless and helpless =(
Remember, you don't fail unless you give up trying to succeed!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: spawning 10 enemy prefabs and assigning a unique health to each one?
« Reply #3 on: November 27, 2012, 01:57:50 AM »
Hi Jean :)

thanks for taking your time to find these for me. I  have already done a search, and so i have already read those posts withoutmuch luck :(

What i need is not a way to display health bars on the gui - what i need is a way to track what target my bullet hit and then take health from Them. I have tried making a local var on the enemy prefab for health and setting it to 100. Then my bullet does a Raycast and checks if the object hit = "zombie" and if its true then stores target GO in a variable and sends event to that zombie to lose 25 health (which is done on the zombie prefab)

This sounds to me like it should work but it doesnt :(

So what i need is to cd able to have 10 of the same zombie spawned and be able to track health and hits on each one individually


Any help or pointers could get me going, but i cant figure out how to do it myself Even after 10th+ hours of trying :<
Remember, you don't fail unless you give up trying to succeed!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: spawning 10 enemy prefabs and assigning a unique health to each one?
« Reply #4 on: November 27, 2012, 02:50:58 AM »
Hi,

 Ok, I see. for this, I can only recommand TargetPro. This will allow you do that and a lot more. you can assign effect and damages for your projectily and targets being hit by these projectile will then have their health affected accordingly.

https://hutonggames.fogbugz.com/default.asp?W993

 bye,

 Jean

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: spawning 10 enemy prefabs and assigning a unique health to each one?
« Reply #5 on: November 27, 2012, 05:44:46 PM »
Thanks alot Jean, I will take a look at it! :)
Remember, you don't fail unless you give up trying to succeed!