virtual public void SetChildVariables(PhysicsController_Child pChild, int i) { pChild.gameObject.SetActive(true); pChild.GetComponent <Rigidbody>().mass = GetChunkMass(); if (!pChild.positionFrozen) { pChild.GetRigidbody().velocity = _myRigidbody.velocity; pChild.GetRigidbody().angularVelocity = _myRigidbody.angularVelocity; } pChild.playerCanBreak = playerCanBreak; pChild._PhysicsController = _physicsController; pChild.SetChunkProperties(); pChild.StackTraceNumber = StackTraceNumber; pChild.passDownBreakage = passDownBreakage; pChild.PassDownContactForce = _PassDownContactForce; if (instantiateSmallCollider && pChild.GetComponent <Collider>() != null) { if (GetComponent <Collider>() != null) { if (instantiateSmallCollider) { InstantiateSmallCollider(pChild.transform); } } } }
virtual public void EnableChildren() { int i = 0; foreach (Transform child in _myTransform) { //cache the child object since we'll be using it alot PhysicsController_Child pChild = (PhysicsController_Child)child.GetComponent(typeof(PhysicsController_Child)); if (instantiateSmallCollider) { InstantiateSmallCollider(child); } if (child.GetComponent <PhysicsController_Child>().positionFrozen) { child.GetComponent <Rigidbody>().isKinematic = child.GetComponent <PhysicsController_Child>().positionFrozen; } else if (child.GetComponent <PhysicsController_Child>().preventBreaking) { child.GetComponent <PhysicsController_Child>().preventBreaking = true; } SetChildVariables(pChild, i); i++; } BreakAndDestroy(); }