x


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?

more ▼

asked Jul 30, 2010 at 07:26 AM

theawesomesheep gravatar image

theawesomesheep
12 6 4 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 30, 2010 at 08:52 AM

qJake gravatar image

qJake
12.7k 92 137 214

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x9278
x6291
x3196

asked: Jul 30, 2010 at 07:26 AM

Seen: 1181 times

Last Updated: Jul 30, 2010 at 07:26 AM