The animations are working, but i can't make it so that when the player stops moving
the animation's sprite frame is zero.

Player Movement:
using Godot;
using System;

public partial class Player : CharacterBody2D
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}

// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
	var walksp = 5;
	
	var up = Input.IsActionPressed("UpKey");
	var down = Input.IsActionPressed("DownKey");
	var left = Input.IsActionPressed("LeftKey");
	var right = Input.IsActionPressed("RightKey");
	var anim = GetNode("AnimationPlayer");

	if (up) {
		this.Position += new Vector2(0,-walksp);
		((AnimationPlayer)anim).Play("Up");
	}
	
	if (down){
		this.Position += new Vector2(0,walksp);
		((AnimationPlayer)anim).Play("Down");
	}
	
	if (left){
		this.Position += new Vector2(-walksp,0);
		((AnimationPlayer)anim).Play("Left");
	}
	
	if (right){
		this.Position += new Vector2(walksp,0);
		((AnimationPlayer)anim).Play("Right");
}
}

}

  • include an else statement at the end, here you can also play your idle animation if you have one.
    if you want to keep the direction your sprite was facing, instead of an idle animation you can just set the frame to zero. Since you are using animation player, you would call the seek function and set it to 0 seconds. You may also need to stop the animation player if you aren't playing anything in this else block.

    something like:

    else{
        ((AnimationPlayer)anim).stop()
        ((AnimationPlayer)anim).seek(0)
    }

include an else statement at the end, here you can also play your idle animation if you have one.
if you want to keep the direction your sprite was facing, instead of an idle animation you can just set the frame to zero. Since you are using animation player, you would call the seek function and set it to 0 seconds. You may also need to stop the animation player if you aren't playing anything in this else block.

something like:

else{
    ((AnimationPlayer)anim).stop()
    ((AnimationPlayer)anim).seek(0)
}