[SOLVED] Walk animation frame problem

Another beginner question here. I’ll try to explain as clearly as I can but since this is about animation, it’s a bit challenging.

I have a topdown RPG. I have walking animations for walking in each (4) directions. If the player is not moving, then the second frame (frame 1, because in my understanding the first frame would be called frame 0) is shown and the animation stops playing (so you stay still like you should).

The first frame of every animation (mainly frame 0, but it’s identical to frame 2) is a “taking step frame”, very different from the “idle frame” (the frame 1 which is used when idle). So when you are facing left in the game and very quickly, shortly press right to turn around, the character turns around, lifts their leg up and takes a quick little step.

However, if I now quickly press right again to move just a little bit more, the step frame (frame 0, but also frame 2, they are the same) does not show up about 70% of the time. This is a problem, because no matter show quick my press is, I want the sprite to take a little step every time.

Let me emphasize that this only happens when I press a specific direction more than once in a row. If I press left, right, left, right, the step frame (0) shows up every time.

I’m thinking this has something to do with how the “change frame” action works. The animation doesn’t reset or something. I don’t know. I’m out of ideas. Help! :slight_smile:

If you press the key too quick the animation wont show up because it goes to frame 1 as soon you unpress the key. Use a boolean variable to check if key was pressed or not.

Sorry but I don’t understand. Yes the animation goes to frame 1 as soon as I unpress the key. And that’s cool. But why doesn’t the animation show while I’m pressing the key? Even if I press it for a short amount of time, it still should show (for that time)

is your diagonal movement animation working?

Are you referring to this post or the one I made while back? I’d rather devote this topic for discussion about this specific problem, not my past problems. If you are talking about one of those old ones, please ask questions about them in their old, own topics :slight_smile: Yes I solved it and I shared my solution.

Have you tried to declare to what animation your last event refers to? Frame 1 of what animation?

No? It refers to whatever animation in currently set to player

Your intuition that the animation isn’t resetting when the code to set it is called again is correct. To solve this, I’d recommend using a separate idle animation instead of an individual frame of the current animation. You can reuse the idle image in the new animation, and it can be a single frame long. May add some complexity by needing 4 new animations for each direction, but its also possible to get the facing direction through events, and add that to a string to set the direction. ie setting animation name to “idle”+object.TopDownMovement::Angle (not exact wording, but hopefully close enough to get you started!)

Edit to add: a way to do so without adding separate animations would be using a boolean to determine if coming out of an idle state or not. After the events for movement, add an event to check a boolean variable if true that the player was idling, and have it set the animation frame to zero and the idle boolean to false. In the event where you set the frame to 1 while the player is not moving, set the boolean to true. An object variable for the player object could work for this.

1 Like

I did it! Thank you so much! Much love.

Here’s how I did it in 2 images, I don’t think there is much to explain:

1 Like