From 41c811afa809a83b5cbec5d4c4b31a349ec352d8 Mon Sep 17 00:00:00 2001 From: mischa Date: Thu, 28 Mar 2024 21:27:17 +0800 Subject: [PATCH] fix(PredictedRigidbody): increase default motion smoothing angular velocity threshold --- .../Components/PredictedRigidbody/PredictedRigidbody.cs | 6 +++--- .../Examples/BilliardsPredicted/Ball/RedPredicted.prefab | 2 +- .../Examples/BilliardsPredicted/Ball/WhitePredicted.prefab | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs index 2a6e24439..715d54070 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs @@ -35,7 +35,7 @@ public class PredictedRigidbody : NetworkBehaviour [Tooltip("Smoothing via Ghost-following only happens on demand, while moving with a minimum velocity.")] public float motionSmoothingVelocityThreshold = 0.1f; float motionSmoothingVelocityThresholdSqr; // ² cached in Awake - public float motionSmoothingAngularVelocityThreshold = 0.1f; + public float motionSmoothingAngularVelocityThreshold = 5.0f; // Billiards demo: 0.1 is way too small, takes forever for IsMoving()==false float motionSmoothingAngularVelocityThresholdSqr; // ² cached in Awake public float motionSmoothingTimeTolerance = 0.5f; double motionSmoothingLastMovedTime; @@ -581,8 +581,8 @@ void RecordState() protected virtual void OnSnappedIntoPlace() {} protected virtual void OnBeforeApplyState() {} protected virtual void OnCorrected() {} - protected virtual void OnBeginPrediction() {} // when the Rigidbody moved above threshold and we created a ghost - protected virtual void OnEndPrediction() {} // when the Rigidbody came to rest and we destroyed the ghost + protected virtual void OnBeginPrediction() => Debug.LogWarning($"BEGIN: {name}"); // when the Rigidbody moved above threshold and we created a ghost + protected virtual void OnEndPrediction() => Debug.LogWarning($"END: {name}"); // when the Rigidbody came to rest and we destroyed the ghost void ApplyState(double timestamp, Vector3 position, Quaternion rotation, Vector3 velocity, Vector3 angularVelocity) { diff --git a/Assets/Mirror/Examples/BilliardsPredicted/Ball/RedPredicted.prefab b/Assets/Mirror/Examples/BilliardsPredicted/Ball/RedPredicted.prefab index 848e31b44..be6aaeb0a 100644 --- a/Assets/Mirror/Examples/BilliardsPredicted/Ball/RedPredicted.prefab +++ b/Assets/Mirror/Examples/BilliardsPredicted/Ball/RedPredicted.prefab @@ -166,7 +166,7 @@ MonoBehaviour: syncInterval: 0 predictedRigidbody: {fileID: -177125271246800426} motionSmoothingVelocityThreshold: 0.1 - motionSmoothingAngularVelocityThreshold: 0.1 + motionSmoothingAngularVelocityThreshold: 5 motionSmoothingTimeTolerance: 0.5 stateHistoryLimit: 32 recordInterval: 0.05 diff --git a/Assets/Mirror/Examples/BilliardsPredicted/Ball/WhitePredicted.prefab b/Assets/Mirror/Examples/BilliardsPredicted/Ball/WhitePredicted.prefab index df1b9664d..e27f121a6 100644 --- a/Assets/Mirror/Examples/BilliardsPredicted/Ball/WhitePredicted.prefab +++ b/Assets/Mirror/Examples/BilliardsPredicted/Ball/WhitePredicted.prefab @@ -302,7 +302,7 @@ MonoBehaviour: syncInterval: 0 predictedRigidbody: {fileID: 1848203816128897140} motionSmoothingVelocityThreshold: 0.1 - motionSmoothingAngularVelocityThreshold: 0.1 + motionSmoothingAngularVelocityThreshold: 5 motionSmoothingTimeTolerance: 0.5 stateHistoryLimit: 32 recordInterval: 0.05