problem with enemy health!

Get help using Construct 2

Post » Mon May 23, 2016 9:38 am

Hi,

i work on defense game and game have many enemies.

i put enemies in enemy family with health instance , then set for soldier 20 , car 50, tank 100 health.

i have mine on game for destroy enemies so when enemies On collision with mine:

enemies(Family) => set health to 0 ( or -1).

i have : enemies(Family) <= 0 =======> enemies Destroy.

but my enemies on collision with mine, their health set with 0 , but do not destroy !

where is the problem?
(sorry for my bad english)
B
10
S
3
Posts: 180
Reputation: 1,212

Post » Mon May 23, 2016 12:45 pm

Hi,

Sounds like you've done everything right. Can you verify that the explosion sets their health to "0" in the debugging mode?

Family.Health <= 0
____ Destroy

That should be enough to identify which unit's health has become <= and remove it. Can you attach your project?
B
8
S
2
Posts: 59
Reputation: 686

Post » Mon May 23, 2016 12:50 pm

sorry i can't attach my project.
but i try for

Family.Health <= 0
____ Destroy

and do not work.
but when i subtract 20 form health, soldier die on first collision and car in 3th collision and tank on 5th , it means it works very good.

but for reason i want set it to zero ! or -1 ! witch not work.

Edit:
With Family.Health <= 0
____ Destroy

some times work good and some time, when enemies collision with mine, in debug view , it health set to my value, but do not destroy , then when another enemies collision , that enemies with 0 health, destroy !!!!
B
10
S
3
Posts: 180
Reputation: 1,212

Post » Mon May 23, 2016 2:13 pm

Not sure what you mean but maybe this:

Put your check for Family.Health OUTSIDE of collision checks. You want it to run all the time, not just when your objects collide.
B
8
S
2
Posts: 59
Reputation: 686

Post » Mon May 23, 2016 2:43 pm

Do you use a system > Compare two values maybe ?

You have to use a pick condition to pick those ...

System > conditions > Pick by comparison > Object = the family / Expression = Family.Health / <= / value = 0
Action > Family > destroy

I hope you made that variable on the familie.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon May 23, 2016 3:17 pm

@Lncredible thank you for your help.

@99Instances2Go thank you very much, your way very good. why my way has problem?
B
10
S
3
Posts: 180
Reputation: 1,212

Post » Mon May 23, 2016 3:47 pm

There is no problem in your way. It just selects no objects. The action > destroy needs selected objects to do its magic on.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon May 23, 2016 8:15 pm

hi again,

i found bug on my game and action,
when 3 enemies health set 0 on one time for example, nothing happend and enemies with 0 health or negative health , are alive !

i try my code in Every tick, but the problem not solved.
B
10
S
3
Posts: 180
Reputation: 1,212

Post » Mon May 23, 2016 9:47 pm

Need to see your code.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests