Making a group of cubes collapse
Hey guys! So I made a sheep out of a bunch of cubes, and what I want to happen is when the player collides with this sheep, I want it to essentially turn off isKinematic for all the cubes. I already have it so that when the player (a ball) hits the sheep, whatever cube it hits will have isKinematic set to false, however, how could I make it so that when the sheep collides with the sheep, all the cubes have their kinematic state changed to false. Thanks in advance!
Comment
Best Answer
Answer by BlackSnow_2 · Sep 01, 2015 at 02:11 AM
If you set the cubes under an empty GameObject and have the GameObject (Sheep) contain the Kinematic Rigidbody you can use a script like this to change all the cubes at once:
public GameObject Sheep;
void Update () {
if (Input.GetKey (KeyCode.K)) {
Sheep.GetComponent<Rigidbody>().isKinematic = false;
}
if (Input.GetKey (KeyCode.N)) {
Sheep.GetComponent<Rigidbody>().isKinematic = true;
}
}