- Home /
falling block bridge
I have a bridge set up of 20 blocks. I have a script on my character that when he touches a button it starts. I want the bridge to fall 1 block at a time starting from one end to the other. what would be the best way to do this?
Answer by qJake · Jul 30, 2010 at 08:52 AM
Get an array of each block, in order, via script. Then something like this:
// C# // Assumes you have "GameObject[] pieces;" already set up.
IEnumerator BridgeFall() { for(int i = 0; i < pieces.Length; i++) { pieces[i].rigidbody.gravity = true; // or however you make them "fall".
yield return new WaitForSeconds(1);
// or however long you want to wait for.
}
}
Then, just start the coroutine with StartCoroutine(BridgeFall());
whenever you wanted it to fall.
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Realistic Bouncing Effect 1 Answer
Magnetism in javascript 3 Answers
Faux Gravity Prolem? #2 2 Answers