Missing frames in sprite animation

Hey guys, I’ve been watching the youtube tutorials on how to make a 2D platform game.

I have done everything step by step like the videos but I recently encountered a problem when animating some actions.

I just want to make a basic slash attack for my sprite, I imported the different frames and set the animation to slash, made sure all frames where there, looped the animation and double checked collisions boxes etc.

Then I went to my events and created a condition “When g key is pressed” and the according action “Change the animation of Sprite to Slash”.

Now when I press “g” the first frame of the animation plays but not the rest. Considering all my other animations (Idle and Run) work perfectly, what am I doing wrong?

I already tried setting another condition to “Trigger Once” but it didn’t do anything.

Thanks in advance for your replies and sorry if this is a common problem.

Hi, you have set clear instructions which animation to play when your character is moving or not etc. Now when you press g there is a conflict as two animations are supposed to play at the same time. To solve this problem you should add ‘trigger once while true’ to all your animation-related events.

1 Like

Yeah, what Drona said.
Looking through your event sheet, I believe what happens is that when you press g key, it changes animation to “Slash”. However, if the character is not moving, it immediately reverts back to “Idle” in the next frame.

I would suggest setting an object boolean variable for the slash.
Let’s say you have a variable “slashingnow”.

Conditions:
If Mimis is moving and Mimis is on the floor and slashingnow is false,
Action:
Change animation to “Run”

Do the same with Mimis not moving.

When you press “g”, set variable “slashingnow” to true. And change animation to “Slash”.

Add another event:
Conditions:
If Mimis animation is “Slash” and when animation is finished:
Action:
Set variable slashingnow to false.

I’m not sure if I got it correctly but I believe that’s pretty much the gist of it.

1 Like

Thank you for your response! I did what you said and everything works fine, the animation is now playing all the frames. The only problem I encountered doing this is that now my animation is looping infinitely. Only way for it to stop is triggering another animation by pressing the jump or directionals keys. Any way to solve this other issue?

Hey, thank you so much for your time! Like I said in reply to Drona, his solution resolved my problem but triggered another one. By just looking at what you said (I’m not home atm to test it) I definitely think you answer will resolve all of the issues above. I’m only a noob in GDevelop so I will have to get a real look at this later today.
I’m trying to keep this as simple as possible as I am a visual learner but I will try to decrypt what you said lol. Thank you so much for your time and elaborate response.

Yeah, I forgot to add the “trigger once” on my suggested events. Also you mentioned the animations are looping. I think only the run animation should be set to loop (and maybe the idle also if the character is breathing or doing some movement while idle) while the slash animation probably shouldn’t be set to loop, otherwise the condition to change the variable when slash animation is finished might not trigger. So yeah. Good luck!