From 29bf869bd11c70b97236daed0d1722770170854b Mon Sep 17 00:00:00 2001 From: MaddoScientisto Date: Tue, 25 Mar 2025 19:21:42 +0100 Subject: [PATCH] Player Animation based on speed --- Scripts/Components/Actors/PlayerAnimationProvider.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Scripts/Components/Actors/PlayerAnimationProvider.cs b/Scripts/Components/Actors/PlayerAnimationProvider.cs index 4dd18cf2..7c388cd9 100644 --- a/Scripts/Components/Actors/PlayerAnimationProvider.cs +++ b/Scripts/Components/Actors/PlayerAnimationProvider.cs @@ -56,13 +56,21 @@ public partial class PlayerAnimationProvider : Node2D public void SetAnimation(Vector2 velocity) { - if (velocity.X == 0 && velocity.Y == 0) + if (velocity.Length() == 0) { _animatedSprite.SpeedScale = 0; } else { - _animatedSprite.SpeedScale = 1; + if (velocity.Length() > 40) + { + _animatedSprite.SpeedScale = 1; + } + else + { + _animatedSprite.SpeedScale = 0.8f; + } + } if (velocity.X > 0)