diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs index 585c66cfc..eaa2a53ab 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs @@ -148,8 +148,7 @@ protected virtual void CreateGhosts() physicsGhostRigidbody.ghostEnabledCheckInterval = ghostEnabledCheckInterval; // move the rigidbody component & all colliders to the physics GameObject - PredictionUtils.MoveRigidbody(gameObject, physicsCopy); - PredictionUtils.MoveAllColliders(gameObject, physicsCopy); + PredictionUtils.MovePhysicsComponents(gameObject, physicsCopy); // show ghost by copying all renderers / materials with ghost material applied if (showGhost) @@ -182,8 +181,7 @@ protected virtual void DestroyCopies() // otherwise next time they wouldn't have a collider anymore. if (physicsCopy != null) { - PredictionUtils.MoveRigidbody(physicsCopy, gameObject); - PredictionUtils.MoveAllColliders(physicsCopy, gameObject); + PredictionUtils.MovePhysicsComponents(physicsCopy, gameObject); Destroy(physicsCopy); } diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs index 8a7b31e3a..09fea9555 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs @@ -142,5 +142,12 @@ public static void MoveAllColliders(GameObject source, GameObject destination) MoveCapsuleColliders(source, destination); MoveMeshColliders(source, destination); } + + // move all physics components from one GameObject to another. + public static void MovePhysicsComponents(GameObject source, GameObject destination) + { + MoveRigidbody(source, destination); + MoveAllColliders(source, destination); + } } }