diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs index d85c37b0a..443f491cd 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs @@ -53,6 +53,12 @@ public static RigidbodyState Interpolate(RigidbodyState a, RigidbodyState b, flo } } + public enum CorrectionMode + { + Set, // rigidbody.position/rotation = ... + Move, // rigidbody.MovePosition/Rotation + } + [RequireComponent(typeof(Rigidbody))] public class PredictedRigidbody : NetworkBehaviour { @@ -75,8 +81,8 @@ public class PredictedRigidbody : NetworkBehaviour public bool oneFrameAhead = true; [Header("Smoothing")] - [Tooltip("Enable this to use Rigidbody's MovePosition/Rotation instead of directly setting .position/.rotation. This is recommended!")] - public bool smoothCorrection = true; + [Tooltip("Configure how to apply the corrected state.")] + public CorrectionMode correctionMode = CorrectionMode.Move; [Header("Debugging")] public float lineTime = 10; @@ -117,12 +123,12 @@ void ApplyState(Vector3 position, Quaternion rotation, Vector3 velocity) { // Rigidbody .position teleports, while .MovePosition interpolates // TODO is this a good idea? what about next capture while it's interpolating? - if (smoothCorrection) + if (correctionMode == CorrectionMode.Move) { rb.MovePosition(position); rb.MoveRotation(rotation); } - else + else if (correctionMode == CorrectionMode.Set) { rb.position = position; rb.rotation = rotation;