mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
chore: old unity compat for PredictedRigidbody (#3781)
This commit is contained in:
parent
9ce8f9b5f8
commit
074e0d6dc6
@ -348,6 +348,17 @@ protected virtual void SmoothFollowPhysicsCopy()
|
||||
// float positionStep = (distance * distance) * interpolationSpeed;
|
||||
float positionStep = distance * positionInterpolationSpeed;
|
||||
|
||||
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
|
||||
Quaternion newRotation = Quaternion.Slerp(currentRotation, physicsRotation, rotationInterpolationSpeed * deltaTime).normalized;
|
||||
|
||||
// assign position and rotation together. faster than accessing manually.
|
||||
tf.SetPositionAndRotation(newPosition, newRotation);
|
||||
}
|
||||
|
||||
// simple and slow version with MoveTowards, which recalculates delta and delta.sqrMagnitude:
|
||||
// Vector3 newPosition = Vector3.MoveTowards(currentPosition, physicsPosition, positionStep * deltaTime);
|
||||
// faster version copied from MoveTowards:
|
||||
@ -374,17 +385,6 @@ static Vector3 MoveTowardsCustom(
|
||||
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
|
||||
Quaternion newRotation = Quaternion.Slerp(currentRotation, physicsRotation, rotationInterpolationSpeed * deltaTime).normalized;
|
||||
|
||||
// assign position and rotation together. faster than accessing manually.
|
||||
tf.SetPositionAndRotation(newPosition, newRotation);
|
||||
}
|
||||
|
||||
// destroy visual copy only in OnStopClient().
|
||||
// OnDestroy() wouldn't be called for scene objects that are only disabled instead of destroyed.
|
||||
public override void OnStopClient()
|
||||
|
Loading…
Reference in New Issue
Block a user