x


ArgumentException: RandomRangeInt can only be called from the main thread.

I am getting this compile error when I try and run this script: RandomRangeInt can only be called from the main thread.

private var random = Random.Range(0, 4);

function Update () 
{
    print (random);
}

Any Idea on how to solve this??

--Thanks!

more ▼

asked Jan 10 '12 at 03:53 AM

sjj100 gravatar image

sjj100
1 1 2 4

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

1 answer: sort newest

Yeah, don't try to run that Random command on variable init, do it this way:

private var random : int;

function Start () 
{
     random = Random.Range(0, 4);
}

function Update () 
{
    print (random);
}

If you want it to continuously make new random numbers, put that line from Start into Update also.

more ▼

answered Jan 10 '12 at 05:47 AM

Tasarran gravatar image

Tasarran
1.1k 12 21 27

Thanks much!!!

Jan 10 '12 at 08:41 PM sjj100
(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:

x1951
x573
x76
x38

asked: Jan 10 '12 at 03:53 AM

Seen: 1319 times

Last Updated: Jan 10 '12 at 08:41 PM