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");
}
}
}