Random animations stopping?

Hey, guys. I’m trying out my first game here and I’m kinda stuck. I have an enemy perform a random animation, then after the animation completes (0.8 seconds), the enemy’s supposed to pick another random animation and perform it. However, he freezes, doesn’t return to idle, and doesn’t pick a new animation. I’ve gone through the sequence 50x in my head and can’t figure out what I’m doing wrong.
Any help would be greatly appreciated. Thanks!

попробуй использовать “Animation finished” в условии.
Если хочешь использовать таймер, тогда его нужно обнулять после каждого действия, чтобы отсчет начинался заново.

I use the timer to get HP.

Generic reminder: Anytime you use a condition that results in setting the animation of an object make sure you add “Trigger Once” to the condition or else it will constantly play only the first frame.

In your case you are using a boolean gate with “EnemyAct” to ensure that each EnemyAnimation condition only gets called once, which is good. However, the final conditionaly just checks if EnemyAct is true (which is will be after each of the preceding conditionals) so it will always reset the animation to the first frame of “EnemyIdle”.

Furthermore, you should consider rewriting this entire block to use the “Animation is Finished” conditional. Then you can just select an random animation, play it, and when it’s finished do that again. It would be three lines of code total, instead of three lines of code for each animation state.


I’m sorry, but could you throw together an example for me? I must be missing something from your explanation :frowning:
And the idle animation is on a loop. Does that not interfere with the Animation is Finished conditional?
And I had the “Trigger Once” condition set before I took the screenshot, but I took it away thinking that it was the cause of the problem :stuck_out_tongue:
Again, thanks.

Just do try this:
If EnemyAction timer is > 0.8 second
Trigger Once
Set animation number of Enemy to (RandomInRange(1,4))
Reset Timer EnemyAction

1 Like

Brilliant, thank you, sir. If I could somehow give you karma, I would :stuck_out_tongue: