How do I Set individual health variable in a family?

Get help using Construct 2

Post » Tue Jan 19, 2016 8:23 pm

Hello,

I'm having a bit of trouble with this one. I have Enemy 1, 2, and 3. Their health is to be 10, 20 and 30 respectively. I placed them in a family called "Enemies". I've been trying for a bit to make it so when a bullet collides with the "enemies" family, it reduces that instances health by one. But I can't just set a health variable through the family for all of them because each type of enemy has different health totals, and I can't subtract one from three family health variables (health1, health2, heath3) because that kills all enemy 1's if enemy 2 is shot ten times. So how do I subtract from unique health variables upon a family collision condition?

Thanks,

William
B
8
Posts: 25
Reputation: 356

Post » Tue Jan 19, 2016 9:54 pm

"Health" has to be a family instance variable. Next, the simplest method would be to add "On created" trigger for each of your enemy.

Enemy 1 -> On created -> Set Enemy 1 "Health" variable to 10
Enemy 2 -> On created -> Set Enemy 2 "Health" variable to 20
...

The collision event will now have to look like this :
Enemies -> On collision with bullet -> Subtract 1 from "Health"
B
62
S
26
G
24
Posts: 954
Reputation: 18,318


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests