diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs index 46bd3ec45..13e5160a6 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs @@ -364,15 +364,18 @@ static Vector3 MoveTowardsCustom( if (_sqrDistance == 0.0 || maxDistanceDelta >= 0.0 && _sqrDistance <= maxDistanceDelta * maxDistanceDelta) return target; + float distFactor = maxDistanceDelta / _distance; // unlike Vector3.MoveTowards, we only calculate this once return new Vector3( - current.x + (_delta.x / _distance) * maxDistanceDelta, - current.y + (_delta.y / _distance) * maxDistanceDelta, - current.z + (_delta.z / _distance) * maxDistanceDelta); + // current.x + (_delta.x / _distance) * maxDistanceDelta, + // current.y + (_delta.y / _distance) * maxDistanceDelta, + // current.z + (_delta.z / _distance) * maxDistanceDelta); + current.x + _delta.x * distFactor, + current.y + _delta.y * distFactor, + current.z + _delta.z * distFactor); } Vector3 newPosition = MoveTowardsCustom(currentPosition, physicsPosition, delta, sqrDistance, distance, positionStep * deltaTime); - // smoothly interpolate to the target rotation. // Quaternion.RotateTowards doesn't seem to work at all, so let's use SLerp. // Quaternions always need to be normalized in order to be a valid rotation after operations