PredictedRigidbody: make .predictedRigidbody accessible to other components!

This commit is contained in:
mischa 2024-03-13 13:25:35 +08:00 committed by MrGadget
parent 00069b9c7c
commit 7702db6e03

View File

@ -24,7 +24,12 @@ public enum CorrectionMode
public class PredictedRigidbody : NetworkBehaviour public class PredictedRigidbody : NetworkBehaviour
{ {
Transform tf; // this component is performance critical. cache .transform getter! 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; Vector3 lastPosition;
// motion smoothing happen on-demand, because it requires moving physics components to another GameObject. // motion smoothing happen on-demand, because it requires moving physics components to another GameObject.