Kinematic Help
Hi, Trying to make a building collapse but only after 2 of the 4 main structure pillons are down. I have added :
public GameObject IsImportantStructure1; public GameObject IsImportantStructure2; public GameObject IsImportantStructure3; public GameObject IsImportantStructure4; public GameObject GroupObjectsToFall; private Component[] RigidbodyKinematics;
And now i am having trouble with the next code because sometimes it works and the building collapses and other times it doesn't apply the kinematics off to all the children in the gameobject
if (this.gameObject == IsImportantStructure1 || IsImportantStructure2 || IsImportantStructure3 || IsImportantStructure4) {
if (IsImportantStructure1.GetComponent<Rigidbody> ().isKinematic == false || IsImportantStructure2.GetComponent<Rigidbody> ().isKinematic == false || IsImportantStructure3.GetComponent<Rigidbody> ().isKinematic == false || IsImportantStructure4.GetComponent<Rigidbody> ().isKinematic == false) {
RigidbodyKinematics = GroupObjectsToFall.GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody ApplyPhysicsToThis in RigidbodyKinematics)
ApplyPhysicsToThis.isKinematic = false;
}
}
this.gameObject.GetComponent<Rigidbody>().isKinematic = false;
Thank you
Comment