Everything was working fine before i added Health variable (Number 3rd event and condition)
I want to assign health 2 to every Zombie
Alright, what’s the problem?
At First It Shows Zombies Coming out of screen But when i add if health = 0 delete Enemy. Then dont a single one came
Is because you’re setting health=0 to all zombies, do this Create a group add the enemies to the group then when you create an enemy assign health = 10 use a foreach event to check the health of the enemies and it will work.
Like
Foreach EnemiesGroup
if EnemiesGroup variable health <=0
EnemiesGroup Delete
This way when you create an enemy a health will be added and since you’re in a foreach loop this will check all occurrences of enemies in game and if there is some below 0 then delete.
Where?
This is a condition, so it’s not here :
And these are non-zero values :
The only way I can see it being 0 is that @Diven already has placed some EnemySmall objects on the scene in the editor, and his default health value is 0 for these objects.
@Diven, in the object editor, set the default value of the health variable to 2. Then keep this event as is :
and make this a subevent of the one above :
A few comments from things I’m seeing here:
- If you intend to use “For Each” for an object/object group, you should use 1 parent “For Each” event with subevents. Not multiple “For Each” events. This is both from a performance perspective, as well from an event logic perspective. ForEach loops are separated from each other, so if you’re intending something to happen in For Each A to also impact For Each B, it may not occur.
- Even if you’re immediately changing the Direction variable of EnemySmall to 0, you should still use “Trigger once” as a condition on your 4th and 5th event in your screenshot.
- Rather than using “Change the variable Health of EnemySmall” at the start of the scene, just set up an object variable with a default value of 2, in the object list. It’ll automatically apply to all instances.
None of the above may fix your issue, but they are all relatively important.