[SOLVED]Stuck animation

My animation for sprinting of the player when key Z is pressed in a platformer game is stuck on only one frame. How to fix it?

Try adding trigger once to it

What do you mean by “stuck on one frame”? Do you mean the player only moves one frame when pressing Z or the actual animation is stuck on one frame?

If it’s the second one, go into your animations and make sure that “Loop” is checked for your “Sprinting” animation. This will make it so the animation loops infinitely until another animation is triggered.

Hope that helps!

When you change an animation, GDevelop behaves in one of two ways. If the animation stays the same (so change to “walk” and it’s already “walk”), then GDevelop does nothing. But if the animation changes to a different one (like “walk” changes to “run”), then GDevelop will start the run animation from the first frame.

With this in mind, your problem arises because you are setting the animation to walking when the horizontal arrow keys are pressed, but to sprinting when the z key is pressed. Because the arrow key sets the animation to “walking”, when GDevelop get to the z key part, it resets the animation to “sprinting” and to the first animation frame. This happens every processing frame, or every single time GDevelop get to that event.

A quick fix is to add a subevent to each of the left/right key press events, move the “change to walking animation” actions into the subevents and add a condition to those subevents that checks the current player animation isn’t sprinting.

Like that?(I re-edit the code again)


But it made the Sprint function not working

Yes, all character animations on my player’s movement for “Loop” is checked. :slight_smile:

1 Like

No. That’s not what I had suggested. When I wrote my previous post when I was quite tired and missed the conditions using the Sprint boolean variable. So my suggestion won’t help.

The code you had looked fine. My explanation of why the bug occurs still stands.

I’m assuming the stuck animation is the first sprinting animation frame. If so, it’ll be because of an animation change and a change to the Sprint boolean variable in another event.

So you mean the the two “change animation to walking” on the key left/right pressed event and the “change animation to sprinting” in its sub-event is causing the problem as both of the animations are playing the same time?
If so, how should I fix it then, I still can’t figure it out even after watching so many tutorials

What you had in your original post should be sufficient.


I think it’s happening somewhere else in events that haven’t screen snipped. I’d start by looking for all event actions that change the Sprint boolean variable.

Maybe you’re right.


Is it because of the boolean variable change at start of the game above the event sheets?

Yes, that will be causing the problem. Move that action into the very first event, so it only gets set at the start of the scene, rather than every game frame.

I did so, but it the sprint animation is still stuck on first frame

Change the key left and right events to what they were like in your first post. As they are, they will not work. See my explanation a few posts back if you want to understand why…

1 Like

Geez it finally works now! Thank you so much! But won’t flip horizontally, let me add it’s code…

Yup it’s done and works. Thanks MrMen and whoever tried to help :).