Exemple #1
0
        public void FreezeRigidbody(Rigidbody rigidbody)
        {
            StoredPhysicsData storedPhysicsData = rigidbody.gameObject.GetComponent <StoredPhysicsData>();

            if (storedPhysicsData == null)
            {
                storedPhysicsData = rigidbody.gameObject.AddComponent <StoredPhysicsData>();
            }
            if (storedPhysicsData != null)
            {
                storedPhysicsData.StoreDataFromRigidBody(rigidbody);
            }
            rigidbody.constraints = RigidbodyConstraints.FreezeAll;
            rigidbody.useGravity  = false;
        }
Exemple #2
0
 public void UnFreezeRigidbody(Rigidbody rigidbody)
 {
     if (rigidbody.constraints != RigidbodyConstraints.None)
     {
         rigidbody.constraints = RigidbodyConstraints.None;
         rigidbody.useGravity  = true;
         rigidbody.ResetInertiaTensor();
         StoredPhysicsData storedPhysicsData = rigidbody.gameObject.GetComponent <StoredPhysicsData>();
         if (storedPhysicsData == null)
         {
             storedPhysicsData = rigidbody.gameObject.AddComponent <StoredPhysicsData>();
         }
         if (storedPhysicsData != null)
         {
             storedPhysicsData.SetRigidbodyFromStoredData(rigidbody);
         }
     }
 }