In the `_physics_process` function, add a line to check whether you are walking or aren't walking. You can do this by checking whether `input_dir` is true or false. Optionally, set the animation speed to `speed / base_speed`. This will make it so when the player is walking, your animation speed is 1. If the player is sprinting, your animation goes up and if the player is crouching your animation speed goes down.
In the `toggle_sprint` function, add a line at the end where if `is_sprinting` is true, your animation is set to sprint.
In the `toggle_crouch` function, add a line where if `is_crouching` is true, your animation is set to crouch.
To check if the player is in the air, add a line in the `_physics_process` function where it says `if not is_on_floor():`set your animation to falling/in the air. Add an else statement to change it to the normal state.