Prediction: physics copy now has the correct layer assigned to fix predicted objects falling through the ground in games which use custom physics collision matrix

This commit is contained in:
mischa 2024-01-22 12:11:25 +01:00
parent 3e254f9ef9
commit 673500b226

View File

@ -208,6 +208,10 @@ protected virtual void CreateGhosts()
physicsCopy.transform.rotation = transform.rotation; physicsCopy.transform.rotation = transform.rotation;
physicsCopy.transform.localScale = transform.localScale; physicsCopy.transform.localScale = transform.localScale;
// assign the same Layer for the physics copy.
// games may use a custom physics collision matrix, layer matters.
physicsCopy.layer = gameObject.layer;
// add the PredictedRigidbodyPhysical component // add the PredictedRigidbodyPhysical component
PredictedRigidbodyPhysicsGhost physicsGhostRigidbody = physicsCopy.AddComponent<PredictedRigidbodyPhysicsGhost>(); PredictedRigidbodyPhysicsGhost physicsGhostRigidbody = physicsCopy.AddComponent<PredictedRigidbodyPhysicsGhost>();
physicsGhostRigidbody.target = this; physicsGhostRigidbody.target = this;