How to check if a sprite is almost dead

Hi, I have a enemy with 500 of health and when he’s hit by a bullet, he lose 30 hp. I want that when he’s 100 hp, he change the animation to a different one. There’s a way to do it without using variables? Like: WHEN ENEMY IS 100 hp ----> change animation by name.
I know how to do it with variables but since I have many enemies, it will be a mess, so, ther’s a different way?

I don’t believe there’s a way to do it without variables. I suppose you could offload it to a custom behaviour, but you’d just offload it. You’ll still use variables, just in a different (slightly more organized) place.

Toodles!

What do you mean by this? I don’t understand how having many enemies makes it messier. What are the variables doing or keeping track of?

Because I have like 5 enemies that can spawn simultaneously so I THINK is a bit a mess. Maybe I’m wrong. Anyway, do you think I can do in a different way?

You can use Object variables instead of scene variables.
You can assign an Object variable like
Enemy obj_var_hp = 500

If you have various types of enemies the most easy way is t create Groups and add those enemies into, then use a foreach Enemies to check each one of them.

This is an example of EnemiesGroup

And an Event to check my player Sword in collision with the EnemiesGroup

1 Like