PersistentTrails.CraftLoader.setColliderStateInChildren C# (CSharp) Method

setColliderStateInChildren() public static method

public static setColliderStateInChildren ( GameObject rootObject, bool newValue ) : void
rootObject UnityEngine.GameObject
newValue bool
return void
        public static void setColliderStateInChildren(GameObject rootObject, bool newValue)
        {
            //disable colliders by setting them to isTrigger so you can still run code on them
            Collider[] colliders = rootObject.GetComponentsInChildren<Collider>(true);
            for (int i = 0; i < colliders.Length; i++)
            {
                colliders[i].isTrigger = !newValue;
                colliders[i].material = getPhysicMaterial();
            }
        }

Usage Example

 public void goOffRails()
 {
     _isOffRails = true;
     if (!offRailsInitiliazed) // run once on each offRails activation
     {
         if (rbody == null)
         {
             setupRigidBody();
         }
         if (rbody == null)
         {
             return;
         }
         rbody.isKinematic   = false;
         rbody.velocity      = currentVelocity;
         offRailsInitiliazed = true;
         CraftLoader.setColliderStateInChildren(ghost, true);
         if (offRailsObject == null)
         {
             offRailsObject = ghost.AddComponent <OffRailsObject>();
         }
         else
         {
             offRailsObject.enabled = true;
         }
     }
 }
All Usage Examples Of PersistentTrails.CraftLoader::setColliderStateInChildren