diff --git a/scripts/Player.cs b/scripts/Player.cs index d6eb815..908505d 100644 --- a/scripts/Player.cs +++ b/scripts/Player.cs @@ -24,11 +24,24 @@ public partial class Player : CharacterBody2D { velocity.X = direction.X * Speed; velocity.Y = direction.Y * Speed; + + var animationName = "sideways"; + if (velocity.Y > 0.001f) + animationName = "down"; + else if (velocity.Y < 0.001f) + animationName = "up"; + + if (velocity.X != 0) + animationName = "sideways"; + + Sprite.FlipH = velocity.X < 0.001f && animationName == "sideways"; + Sprite.Play(animationName); } else { velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); velocity.Y = Mathf.MoveToward(Velocity.Y, 0, Speed); + Sprite.Stop(); } Velocity = velocity;