2D TopDown: idle always faces right when stop moving

Hello Im doing a 2D TopDown type of proyect (Not Hotline Miami style but Undertale, Warpman style) from zero. Everything works fine except that If I move left, up or down: when I release the button the animation goes back to the idle facing right. Im not sure what Im lacking. Here I give you some pics of the bluprints! Everything is in the 2Dpaper_character bluprint!

And this is the State Machine I reference in the Update Animation

Page 3 shows if everything is false set the animation state to idle.

In the idle state does your character face right? If so maybe you will need to create an idle flipbook for each direction?

Keep your bools for setting the animations for moving, but only change states when the next direction button is pushed.

So… If you push the up button the IsUp bool sets true while its being pressed. Also on pressing the up button set the animation state to up. When the up button is released, the IsUp bool goes false, which stops the up moving animation but dont change the animation state yet. Leave it set to up. So when the next direction button is pushed, like the left button, set the IsLeft bool to true and now set the animation state to left. Left animation plays till button is released, animation stops at release but stays in the left animation state.

Rinse repeat… If that makes sense…


Hi , thanks for the taking the time.

First, yes! I thougth about making one for every direction and have an idea of how to detect the last direction but there should be a simpler, cleaner way.

In the last paragraph you talking about key events? I dont have those, I want to make it so the keys are rebindable. I may be wrong but using key events wont be against that?

Well when I was referring to say the up button, you could use a key such as the up arrow key or have an action mapping set in the project settings for lets say MoveUp which could be also set to the up arrow key. So when you pressed the up arrow key both the up keyboard event and the input action MoveUp would fire off.

As for being able to change key bindings eh… well I’m not sure how to do that so I suppose maybe that would affect the input action mappings or maybe not?

Input action Mappings are only activated for one frame on the pressed and then again on the release. Where as the axis mappings are activated once per frame every frame that the key is being held down. Like an Event Tick.

So if you set an action mapping for the Up Arrow lets say as SetMoveUp and set an axis map as UpMovement using the up arrow key also. When you first press the up arrow key the SetMoveUp action map will fire off only once. While you hold the up arrow pressed the axis mapping will continue to fire off till you release the key. Upon release of the up arrow key, the SetMoveUp action map will fire off once and at the same time stop the axis mapping UpMovement.

So on key press down, you could set a bool to true, on key release set the bool to false. At the same time when the key is being pressed set an axis movement, in this case up. on release the movement stops.

So in your game on key press set the direction bool to true using an action mapping at the same time the key is also set for an axis mappings for your movement. On the key release the movement would stop and none of the direction bools would go true so your character would remain facing which ever direction he was facing till you pressed a different direction key.

Also instead of using an action mapping, you could just use the keyboard input up, for the up arrow or whatever direction or key you want. The keyboard inputs only fire off one time on pressed or released.

Again hope this is helping not confusing you. Maybe I’m confused. heh


Actually I’m not sure you need an input action map. Or the keyboard input. Just keep it like you have it with checking to see if the axis map value is equal to 0. Really I think… you only need to remove the idle animation from page 3.

But the action map or the keyboard input may help with performance since those aren’t reading and checking a value every frame. Just some ideas… heh

Wait, wut. That “InputAction MoveUp” How does it have Pressed and Released? Mine dont have that, look at page 2. May it be because I set them in the axis mapping instead of action mapping? But actionmappings dont have the +1 -1 axis going on, I havent researched how to set movement with those (the action ones)

So basically, keep using the axismaps from the proyect settings only for the movement, and “replicate” them but in the actionmaps and use those to set the diferent animations. Of course changing how the boleans are collected and stuff from the page 3.

Yes, sounds really good. Its 3AM here so Im gonna test it tomorrow and tell you what happened! Thank you <3

Sorry for the lateness. Alright, It certainly works! There is just another problem now, If you press to go up, and while you keep pressing it you now press left: the one you release first will change to its idle version even when you keep moving.

I dont know if im explaning myself. For example: Go UP, while pressing that now you go LEFT, seconds later you release the LEFT button. Now you move up with the left idle animation.

But if you release the UP button instead…it works fine, I dont get why if all are treated the same in my bluprint

This are the changes I did, this one replaces whats on page 1, of course there is also for Up and Down:

The moving variables here are the locals as I said before, the idling ones are not:

Oh I see you added something to your project! Nice! But still having some issues, hmm. Well I made up a little quick idea for what I was thinking the last time. You might find it easier then what you been trying assuming it even works. lol…

So here goes:

In my example I set up an enumeration blueprint for movements, up, down, right, left. I can use this then to switch to the proper animations both idle and moving.

In project settings I set up two axis mappings, MoveUpward, and MoveSideways. I’m using the arrows keys for this but it doesn’t really matter, set it however you would like.

I set a custom event in my controller blueprint as SwitchMovementEnum and have it wired to the event tick. You will also need a couple variables, one for setting if moving, which I set as MovingAnim (true will be moving, False would be idle) and an enumeration variable, SetDirectionEnum, to set movement direction enums.

Ok now the lets see the custom event at work:

So I start the event with a Sequence, which will run through and check 5 branches. Each of these branches are checking for the input axis values from the get functions, Get MoveUpward and Get MoveSideways. These values will be zero if no keys are being pressed. If thats the case then the #4 on the sequence sets the MoveAnim bool to false.

Which if that is false, brings us to the next branch in the middle of the chain check the bool of MovingAnim, since its false, the switch on Movement_Enum can now set the direction for the Idle animation. What ever the last movent key that was pressed, would have set the DirectionEnum variable to that direction. Which should be the direction the character is looking.

Contine in next post…

In my example I used print strings to since I dont have paperflip books to see if this in fact works, but with the print strings it did seem to work. So in your game, you of course would switch out the print strings to your animations.

Testing this, lets say you are pressing UP, and holding UP, while holding UP, you press the RIGHT arrow, now your are holding both UP and RIGHT. Since Right was the second key pressed, the RIGHT enum would be set. Should you release the RIGHT key, the enum would switch back to the UP enum.

Now still holding UP, press the LEFT key. Hold both keys, the LEFT enum is set, since it was the second key pressed. releasing the LEFT key, and still pressing UP, the enum goes back to UP. Now should you press and hold UP, AND press and hold Left, then release UP, the Left Enum would be set.

In any case, which ever is the last key to be pressed will set the enum to that enums direction.

Now that the enum is set, should you be pressing a key, the MovingAnim bool is set to true, which would set the switch on Movement Enum to that directions moving animation. When you release the key, MovingAnim bool goes false and the Switch for that sets the direction for what would be your idle animations.

Eh… I hope I helped, and I cross my fingers that what I suggest even works. lol. But like I said It seemed to do what I think you are looking for when I tested it out.


Oops, I made an error in my explanation. I said:
"In any case, which ever is the last key to be pressed will set the enum to that enums direction. "

And I said it a few times, but its actually what ever key is released last sets the enum last. Since the axis value will have a value as long as the keys is being pressed.

So… Pressing up, up value goes to 1, now press left, left value goes to -1. They both have value so both would be true and setting the enum to their direction. In the sequence the farther down you go the higher priority. Since UP and Down are at the top, #0 and #1, then RIGHT and LEFT would take priority since they are #2 and #3. But which ever one has value last is the last one to set the direction enum.

Ok, Im tired and confused. But I think I got it right. hehe.

Good Luck!


Hi !, Its something similar to an idea I had, but the problem is that it only recognizes when its idle but not what idle it is. Still I try it both in a new controller and inside the player bp and sadly for some reason it doesnt play any animation (I remember to change it in the game mode)

Changing between the running animations is not a problem really, it would be nice having a way to say “if there is only one key pressed and .actionmappingreleased. then:”

Well hmm, if you set the SetDiretionEnum variable in my example as the key is being pressed, can’t you then use that to check for which pose to use for the animation whether moving or not moving?

GetMoveUpward = ?
GetMoveSideways = ?

If GetMoveUpward AND GetMoveSideways = 0, set moving False, Else (If not 0), set moving True

If Moving = True, set moving anim pose to SetDirectionEnum, Else (False), set idle anim pose to SetDirectionEnum

If the above is what you’re looking for, I think that’s what I have going on in my example. Maybe it isn’t working as intended but it should be sort of on the right track?

Since the custom event SwitchMovementEnum is on the event tick, it is always being updated. If no keys are being pressed, both Get MoveUpward and MoveSideways will be zero, which will set the moving variable to false. Which then sets the switch off of the directionEnum to an Idle animation. If moving is true, set the switch off directionEnum to a moving anim.

Instead of using an enum to set poses, you could use an integer. Example, on the key press UP after checking if MoveUpward is > 0, set this integer to 0 and set moving to true. On release of the UP key do nothing. Do this for all the key presses, but add 1 to the integer for each key. So up = 0, down = 1, right = 2, left = 3. Now use this this integer to set your pose.

Which would be the same thing as using the enum variable, I think… Heh


Hi I been testing different ways and it doesnt work 100% of the time but its in the right track!
Dont know if it made a diference but first I changed the order of the selection in the state machine, if you see it again you will notice that it was “if not run up, then idle up, then run right, the idle right”.
Now its all the runs first and the idles later.

Then I changed and added this:

I’ll keep working for a better solution. Thank you for taking the time I appreciate it! Hope I can help you in the future!
pd: how do I set this as answered?

Let me know when and if you get it working as you seem to like and post it up here.

As to setting how this post has been answered, Im not sure, since all I did was comment or reply. Maybe I could change one of my comments to an answer? Ill try that. Then you would have to except it as such?

Anywho, good luck!