How can I make my player face in the direction pressed even when they are against a wall?

in 2D
I currently have it set up so the player sprite plays an animation depending on which direction they are moving in. However this makes it so that when the player is abutting wall (in this case a CollisionShape2d) and the direction towards that wall is pressed, the character does not face in that direction as no animation is played because there is no player movement.
I'm looking at trying to set the first frame of the animation on "is_action_just_pressed()" but I don't understand how to access a single frame from AnimatedSprite node.
Tags :
Answers
You probably need to store a Vector2 with the inputs retrieved from the player, and then use that to set the animation instead of the player movement/velocity. Something like this should work (untested):
This is similar to the method I described in this topic for alternating user input for an AnimatedSprite3D node. The main idea is to use a Vector2 that represents the direction the player wants to move towards rather than the direction the player is actually moving. That way, the player will always be looking towards the direction of the input from the player.
For setting the AnimatedSprite frame, I think you can just change the
frame
property of the AnimatedSprite (documentation) to the frame you want to show.That said, I haven't really used the AnimatedSprite node very much, so I might be missing something.
Hopefully this helps!
(Side note: Welcome to the forums!)
Thanks a lot for your detailed response! I'll try to implement this over this weekend and post back my progress.
(Happy to be here! I'm loving Godot so far.)