So, I have this working with 3 other enemies, and it works fine. I have a HP variable for each enemy. when it gets to zero, I have it change to a death animation. On the last frame (frame 3), I have it delete itself. It works on everything else. However, on one enemy, instead of dieing, it switches to the first frame of the idle (animation 0), and it does NOT delete. If i remove the animation change and just delete it, it works fine. it is something about changing to that animation. I have also tried calling the animation number instead of the name.
I am making this game for a game jam, and need to stop working on enemies and start working on the map/sound, but I am stuck here
The problem comes from those events. When you switch to an animation, it starts it again from the beginning. Therefore, your animation will never reach 3 frames, since you are always restarting it and thereby setting the animation frame to 0. what you meant to do is this:
When it is dead, change the animation once, and only continuously check if the time has come for it to be deleted.
Note that this may not work correctly if multiple monkeys are being killed at once, because the trigger once triggers the event generally once, not once per object. Use the trigger once per object extension to have a failsafe event:
Also, what are you using to trigger the ‘dead’ state? I don’t think I have seen that half heart icon before. Is it an extension?
Is using an object variable not a good idea? note: My enemies have different amounts of hp, and different elements of attacks do different damage to each creature
That was what I thought too, and it used to be like that. But it hasn’t been the case with GDevelop lately. Once it triggers an animation, the Set animation... action won’t restart it.
It’s the health extension.
But to your problem. I’m wondering it these two events are countering the MonkeyHP < 0 event :
This was it! Thank you. I did not even see that conflict. I fixed it by adding a “MonkeyHP>0” to both of the alert statuses. So, it will only play the attack or idle if the health is over zero, else it deletes the sprite.
I have not looked into extensions much, but will do so next time. I joined the metroidvania jam, and am working as fast as possible before the 15th of march. Didn’t help that I decided to learn a new engine (I have worked with GBStudio and Solarus before, but not really anything more complex like this). I am spending more time figuring out simple things that actually adding to the game. But, that is how you learn! Anyway, thank you
I will look into Finite states during the next project! If it makes life easier, I am all for it. sadly, I am running out of time for this project, so I don’t have time to redo what I have.