Melee Animation problems

im trying to give my character a melee attack but whenever i press a button to play the animation it sticks to only one frame of the anination and it stops the moment I let it go why is that?

Hi @Kgibbs122 and welcome to the community. Could you show use a screenshot of the events you used to make those mechanics?

Most of the times the problem is that we forget to put the “trigger once” condition, so for each cycle of the game there is a change in the animation, making it look like stuck in the first frame.

1 Like

this is what i used

What must happen when you press the “a” key, and Koro isn’t moving?

  • Since it isn’t moving, it must change animation to number 0.
  • Since “a” key is pressed, it must switch to animation number 4.

In the next game cycle:

  • Since it isn’t moving, it must change animation to number 0.
    etc…

There isn’t a way right now to make only one of them happen. You may use the Attack variable to do it.

  • If Koro isn’t moving, and Attack variable = 0, then change animation to 0

  • If “a” key is pressed, trigger once, make Attack variable = 1, change animation to 4

  • If animation number = 4 and animation is finished, trigger once, Attack variable = 0

This way you use the attack variable to know which animation play, only one animation can be played at a given time, and when the attack animation is over, it cleans the attack variable.

I hope it helps

1 Like

can you give me a picture example for reference

It is as oscuridad666 said. Even though when you press button a gdevelop changing animation number to four but at the same time koro isn’t moving so gdevelop changing animation to 0. (Also note that coding order matter, earlier codes are primary.) To solve this you may add action section a little bit of force. But still using variables helps better. Especially text variable like (state=attacking) or (state=idle). Feel free to ask more.

1 Like

In these events, I check first, if the player isn’t moving, if it is on the floor, and the variable Status is not Attacking. If all of them are true, then the player changes animation to Idle.

If the player moving, on floor and not doing a special attack, nor a normal attack, then he must walk.

If the player is jumping, and he isn’t doing a special attack, then he jumps.

Each possibility is as detailed as it can be, so two animations don’t happen at the same time.

This is the test for the code. Random rooms created on each play, and special inputs for special attack moves.