mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Prediction: MovePhysicsComponents helper function
This commit is contained in:
parent
ea13dc67f9
commit
8564e88d97
@ -148,8 +148,7 @@ protected virtual void CreateGhosts()
|
|||||||
physicsGhostRigidbody.ghostEnabledCheckInterval = ghostEnabledCheckInterval;
|
physicsGhostRigidbody.ghostEnabledCheckInterval = ghostEnabledCheckInterval;
|
||||||
|
|
||||||
// move the rigidbody component & all colliders to the physics GameObject
|
// move the rigidbody component & all colliders to the physics GameObject
|
||||||
PredictionUtils.MoveRigidbody(gameObject, physicsCopy);
|
PredictionUtils.MovePhysicsComponents(gameObject, physicsCopy);
|
||||||
PredictionUtils.MoveAllColliders(gameObject, physicsCopy);
|
|
||||||
|
|
||||||
// show ghost by copying all renderers / materials with ghost material applied
|
// show ghost by copying all renderers / materials with ghost material applied
|
||||||
if (showGhost)
|
if (showGhost)
|
||||||
@ -182,8 +181,7 @@ protected virtual void DestroyCopies()
|
|||||||
// otherwise next time they wouldn't have a collider anymore.
|
// otherwise next time they wouldn't have a collider anymore.
|
||||||
if (physicsCopy != null)
|
if (physicsCopy != null)
|
||||||
{
|
{
|
||||||
PredictionUtils.MoveRigidbody(physicsCopy, gameObject);
|
PredictionUtils.MovePhysicsComponents(physicsCopy, gameObject);
|
||||||
PredictionUtils.MoveAllColliders(physicsCopy, gameObject);
|
|
||||||
Destroy(physicsCopy);
|
Destroy(physicsCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,5 +142,12 @@ public static void MoveAllColliders(GameObject source, GameObject destination)
|
|||||||
MoveCapsuleColliders(source, destination);
|
MoveCapsuleColliders(source, destination);
|
||||||
MoveMeshColliders(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user