Rename the default animation to walk_down
In the Animation panel press Ctrl+Shift+O or
click on the button to add frames from sprite sheet
Assets --> Player --> Player Front Sheet.png
Set Horizontal frames to 14
Repeat the above process to add the following animations
Completed list of animations is below
We need a reference to the AnimatedSprite2D
Variables for the players different speeds
A Variable to toggle attacking
Variables for the direction (Start facing down)
A variable for the animation to play
We need a function to return the direction our player is facing
call this function returned_direction
it received one parameter the current direction
we only want to check x and y axis (not diagonal) so normalize
create a default return direction (side)
if y is more than 0 we are facing down
if y is less than 0 we are facing up
if x is more than 0 we are facing right
if x is less than 0 we are facing left
Create a function to play the walk and idle animations
Call it player_animations
It receives a direction parameter
update the direction they are facing
Add a function to detect the attack key
This is a built-in function called _input
If the attack key is pressed
set the animation name to the attack animation
play that attack animation
Update the process function
create a variable for direction
get the current direction