From ecedc99fc6c567b355394f0a02ce99ab6d195791 Mon Sep 17 00:00:00 2001 From: Zenny Date: Fri, 14 Jul 2023 15:24:33 -0700 Subject: [PATCH] Smooth out follow --- Scripts/NPCFollow.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Scripts/NPCFollow.cs b/Scripts/NPCFollow.cs index 9bcbdfb..e6efde9 100644 --- a/Scripts/NPCFollow.cs +++ b/Scripts/NPCFollow.cs @@ -25,7 +25,12 @@ public partial class NPCFollow : CharacterBody3D if (Position.DistanceTo(playerPosition) >= _followDistance) { LookAt(playerPosition - Velocity, Vector3.Up); - Velocity = Velocity.Slerp(targetPosition * _speed, 0.5f); + Velocity = targetPosition * _speed; + MoveAndSlide(); + } + else if (Position.DistanceTo(playerPosition) > _followDistance - 0.4) + { + LookAt(playerPosition - Velocity, Vector3.Up); MoveAndSlide(); } }