x


Random Number every 5 seconds

I am looking for a java script that will pick out a random number between 0 and 360 every 5 seconds. I already have this:

yield WaitForSeconds(2); randomDirection = Random.Range(0, 360);

Thanks for the help!

more ▼

asked May 20 '11 at 06:45 PM

MrJagaloon gravatar image

MrJagaloon
1 3 3 3

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

5 answers: sort voted first
function Start () {
    InvokeRepeating ("PickRandomNumber", 5.0, 5.0);
}

function PickRandomNumber () {
    // should be obvious from here
more ▼

answered May 20 '11 at 07:18 PM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

Thanks, it worked!

May 22 '11 at 11:49 PM MrJagaloon
(comments are locked)
10|3000 characters needed characters left

Thanks alot!

more ▼

answered May 21 '11 at 12:56 AM

MrJagaloon gravatar image

MrJagaloon
1 3 3 3

Please don't post comments as answers. Also, vote up/accept answers that help you.

May 21 '11 at 01:11 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left

Nevermind.... I don't have time to do this right now and Unity Answers won't let me delete my answer. I'm sorry.

more ▼

answered May 20 '11 at 07:03 PM

jahroy gravatar image

jahroy
3.2k 14 18 42

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

Just add a function Update, with an if statement, calling another function which sets pickNumber to true every 5 seconds.

more ▼

answered May 20 '11 at 07:05 PM

Muzz5 gravatar image

Muzz5
1.2k 68 83 94

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

Nevermind... I don't have time to type an answer and Unity Answers won't let me delete my answer. Sorry.

more ▼

answered May 20 '11 at 07:13 PM

jahroy gravatar image

jahroy
3.2k 14 18 42

(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:

x599
x588
x38

asked: May 20 '11 at 06:45 PM

Seen: 1435 times

Last Updated: May 22 '11 at 11:49 PM