|
|
@@ -21,16 +21,18 @@ public class SmoothFollowAndRotate : SyncScript
|
|
|
|
|
|
public override void Update()
|
|
|
{
|
|
|
- var deltaTime = (float)this.Game.UpdateTime.Elapsed.TotalSeconds;
|
|
|
+ var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
|
|
|
var currentPosition = Entity.Transform.Position;
|
|
|
var currentRotation = Entity.Transform.Rotation;
|
|
|
|
|
|
+ var lerpSpeed = 1f - MathF.Exp(-Speed * deltaTime);
|
|
|
+
|
|
|
EntityToFollow.Transform.GetWorldTransformation(out var otherPosition, out var otherRotation, out var _);
|
|
|
|
|
|
- var newPosition = Vector3.Lerp(currentPosition, otherPosition, Speed * deltaTime);
|
|
|
+ var newPosition = Vector3.Lerp(currentPosition, otherPosition, lerpSpeed);
|
|
|
Entity.Transform.Position = newPosition;
|
|
|
|
|
|
- Quaternion.Slerp(ref currentRotation, ref otherRotation, Speed * deltaTime, out var newRotation);
|
|
|
+ Quaternion.Slerp(ref currentRotation, ref otherRotation, lerpSpeed, out var newRotation);
|
|
|
Entity.Transform.Rotation = newRotation;
|
|
|
}
|
|
|
}
|