How do I Change the animation of an object if it's collided with my character whenever he kicks?

I tried this code but whenever the player kicks, the animation of the rock just jumps straight to the last Animation. I want it to go to the next animation before the player kicks it again.

Try add Trigger Once inside your key pressed logic
Then instead of setting the animation with = doit like +=1

Change the number of the animation of Rock +=1

Firstly, it’s skipping to the last event because of this “phenomenon”:


So in your case, the first event happens, the rock goes into animation 1, then it checks if the animation is = 1, sets it to 2, …

Now, one solution is to use a Timer as a “cooldown” - I’m not sure if the animation is for rock flying or destroyed, but we can use the timer to check if the “a” key has been released.
In my game, here’s how I do it:


First I check if the key is being pressed, then the Timer variable, and if that timer is 0 only then I do the next event.
Said next event sets the Timer variable to 1, so next events which have same condition of Controls.KTimer.Action1 = 0 will not trigger.

Then, at the final event, I check if the key is NOT being pressed, and set the timer variable to 0 again.

Hopefully, you can imagine something similiar for your game. I hope it helps!

1 Like