From 7702db6e036eee2586638df90b6151ae904bd51d Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 13 Mar 2024 13:25:35 +0800 Subject: [PATCH] PredictedRigidbody: make .predictedRigidbody accessible to other components! --- .../Components/PredictedRigidbody/PredictedRigidbody.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs index 1b3715b55..db05c5a72 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs @@ -24,7 +24,12 @@ public enum CorrectionMode public class PredictedRigidbody : NetworkBehaviour { Transform tf; // this component is performance critical. cache .transform getter! - protected Rigidbody predictedRigidbody; // always valid, even while moved onto the ghost. + + // Prediction sometimes moves the Rigidbody to a ghost object. + // .predictedRigidbody is always kept up to date to wherever the RB is. + // other components should use this when accessing Rigidbody. + public Rigidbody predictedRigidbody; + Vector3 lastPosition; // motion smoothing happen on-demand, because it requires moving physics components to another GameObject.