Attack animation only plays first frame

hello, I’m making a platformer game and the player has multiple animations, idle, run, jump, fall, ladder climb, and attack-1, attack-2, and attack-3. And for some reason, all other animations work except the attack ones, they all only play a small split second part of the first frame, I’ve spent a couple of hours looking on this website trying to find a solution and everything I see doesn’t work,

here is my code:

And here is the tutorial I’m following:

I know it must be annoying replying to the same exact problem over and over, but it would mean a bunch to me if I got this figured out

What happens after split second the attack animations are shown? Does another animation start? Are there any other actions that change the animation of Philip that aren’t in the screen shot? Because I can’t straight off see what could be causing it from what you’ve given.

Also, shouldn’t the maximum speed of Philip be set to 0 when the x key is pressed?

Have you preset a value for the inicial Attack of Phillip? Because your first line is a condition, not an action. And your second line should be a subevent.

People have this problem a lot here. The answer is almost always that they are setting the animation every frame and missing a “Trigger Once”.
I’m not sure that’s your issue based on the snippet, but think about whether it’s possible.
Also made add a “Play Animation” on the sprite perhaps?

Trigger once is not the problem of the attack animation, since it is triggered once.
The problem is another animation overwriting it.

Make sure that no other animation is triggered, while your variable attack is >0

after the split-second frame, it just goes back to idle, and the reason his speed is set to 0 is because I don’t want him to move while he is swinging his weapon

how would make sure no other animation is triggered,

Do a conditional check that the Attack object variable is 0 before determining what animation to change to.

It’s in the video, and the programming of the events can be seen at 5:21.

But you are not setting speed to 0, instead you are setting it to 500.

because once the split-second frame plays, the speed is zero, so I cant move afterward

Have you done the conditional check on the object variable Attack as I wrote a few comments back, and as in the tutorial video?

is that it?

also, at the beginning of the video, he made “Attack” an instance variable at 4:52 and in his code the “attack” text is orange,

while mine is blue

1 Like

And this still doesn’t work? It still has the split second animation before changing? Because if you’re still getting the issue, then you must be resetting the object variable Attack somewhere else.

The differences in variable colours is because you’ve chosen dark theme, while WishForge games used Nord theme.

You need to drag your second line from top to the right. It has to be a subevent from the 1st line.

Could you elaborate? 'Cos the second line down is a comment.

And the second event line is already a subevent.

1st line is only a condition without any action.
ok! I was referring to his 1st post.

I still can’t understand why you are changing the speed to 500 when x is pressed.

I think it’s because of the bug - the split second that the attack animation is shown before reverting to a non-attack animation. If OP sets speed to 0, then it never gets set back to 500, because the condition of the attack animation having finished is never met. And then Philip cannot move because speed is always 0.

Better he changes the variable to 0 when he press X, and set it back to 500 when animation has finished.