Walking diagonally animation with c#

Godot Version 4.2.1

Question

Hello, for this code,

Vector2 direction = Input.GetVector("left", "right", "up", "down");
        Velocity = direction * Speed;
		if (direction.Y > 0){
			GetNode<AnimatedSprite2D>("Knight_Animation").Play("walk_down");
		}
		if (direction.Y < 0) {
			GetNode<AnimatedSprite2D>("Knight_Animation").Play("walk_up");
		}
		if (direction.X > 0){
			GetNode<AnimatedSprite2D>("Knight_Animation").Play("walk_right");
		}
		if (direction.X < 0) {
			GetNode<AnimatedSprite2D>("Knight_Animation").Play("walk_left");
		}
        MoveAndSlide();

Whenever I walking diagonally, I only get a still image of the first frame of the animation (left or right, whichever way I was walking). Thanks in advance.

every frame you start animation from begin
use this as reference:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.