(Solved) Problem with Scene Timer on a Stun State For a Fighting Game

So basically I’ve been experimenting with Finite State Machines and External Events for a fighting game. Right now I’m trying to come up with a Stun State for the enemy. When I press a button, the player attacks. The attack animation creates a hitbox. When that hitbox collides with the enemy, I want them to go into the stunned animation, and wait 2 seconds.

Now, I put up a scene timer and a boolean scene value. By default it’s false. When the hitbox collides with the enemy, the boolean value becomes true. While it’s true, the scene timer starts, and when it reaches two seconds, I want the boolean value to go false again. And the enemy to go back to its idle state.

Thing is, when I run the game, I attack the enemy. It goes into the stunned animaiton. But after 2 seconds…it doesn’t go back. It’s just stuck like this. What could be going wrong?

I should mention that this is all an external event containing each state of the enemy. Every other piece of code has been turned off, except for this.

You should always add a “trigger once” condition, or make sure that the “start timer” event will only be called once when the conditions are met, otherwise it will reset forever.

1 Like

Oh damn. I’d experimented with “Trigger Once” before, but I never put it in the right place. Now I just added a new condition that checks if the animation is “stun”. Then it triggers this timer ONCE, and badabing badaboom it’s all reset now. Thanks a lot for the little jolt of inspiration.