Player Animation based on speed

This commit is contained in:
MaddoScientisto 2025-03-25 19:21:42 +01:00
commit 29bf869bd1

View file

@ -56,13 +56,21 @@ public partial class PlayerAnimationProvider : Node2D
public void SetAnimation(Vector2 velocity) public void SetAnimation(Vector2 velocity)
{ {
if (velocity.X == 0 && velocity.Y == 0) if (velocity.Length() == 0)
{ {
_animatedSprite.SpeedScale = 0; _animatedSprite.SpeedScale = 0;
} }
else else
{ {
_animatedSprite.SpeedScale = 1; if (velocity.Length() > 40)
{
_animatedSprite.SpeedScale = 1;
}
else
{
_animatedSprite.SpeedScale = 0.8f;
}
} }
if (velocity.X > 0) if (velocity.X > 0)