Animation not working

Hello

I know there’s a similar topic to mine because I was reading the forum before opening this new topic and I could see a similar question but I didn’t really understand the answer. I’m new and trying to develop a platformer game where the character needs to attack with a sword, the animation consist in 7 frames, but when I attack only the first frame is played. This is my code:

Could you guys show me what to add here? Thanks

When you press x, your player is either moving or not moving, so the animation changes to Walk or Idle. You need to solve that conflict by adding more conditions.

Find out more at: How to make a platform game: player animations [GDevelop wiki]

1 Like

Expanding upon Gruk’s answer, yes - the animation switches back immediately to Walk or Idle, and even if not that, pressing X keeps resetting the animation each frame, so you never see the other 6 frames.

The easiest (but least helpful?) to get around it is to add Trigger Once to the condition of each event that isn’t Jumping.

1 Like

Hello

Thanks for your answer but after checking that it doesn’t explain what I’m trying to do.

That helped but is there a correct way of doing it?

After being able to play the attack animation from first to last frame now I have a different problem, I’ve been looking everywhere and can’t find a solution. When my character is on idle and I attack it gets back to idle, but when my character is running and I attack it gets back to idle but keeps sliding forward.

When I try to solve that it seems that I can only choose to finish the attack animation going back to idle or running, but I can’t set it to when I’m running and I attack and finish the attack animation I go back to running and when I’m in idle and I attack and finish the attack animation I go back to idle. It seems a bit weird but I hope you guys understand what I mean.

And I have a different question I couldn’t find a solution. When I press a key for example x for attack is there a way it only attacks one, and if I want another attack I have to press x again? I’ve tried with trigger only one but didn’t help. Sorry for asking too much guys.

Thanks

When you switch to attack, store the previous animation in a variable. That way, you can restore it later I suppose.

You can use “key is released” instead of “pressed” to trigger only once.