Missing a Method? Random.Range?

MissingMethodException: Method not found: 'UnityEngine.Random.Range'. Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()

 var speedMin;
 var speedMax;
 var radiusMin;
 var radiusMax;
 function Update () {
     direction = Random.onUnitSphere;
     direction.z = 0;
     var speed:int = Random.Range(speedMin, speedMax);
     var radius:float = Random.Range(radiusMin, radiusMax);
     centerPoint = direction * radius + transform.position;

[Edit by Berenger : Code formatting]

more ▼

asked Mar 03, 2012 at 01:22 AM

avatar image

84 36 26 28

Your code doesn't give any errors?

Mar 03, 2012 at 01:37 AM Kleptomaniac

Try Random.RandomRange(speedMin, SpeedMax);

Mar 03, 2012 at 01:51 AM Noran

@Noran: no, look in the docs. It's Random.Range.

@chiggafoo: define your variable types. Also, format code when you post it.

Mar 03, 2012 at 01:58 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

It's because you didn't type your variables to ints or floats. Try this instead:

 var speedMin:float;
 var speedMax:float;

Should make it work.

more ▼

answered Apr 19, 2012 at 06:44 AM

avatar image

124 60 51 55

That's not why. The variables should be typed, but that's not actually relevant to the question, and the code works as-is.

Apr 19, 2012 at 06:56 AM Eric5h5
(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



Answers and Comments



asked: Mar 03, 2012 at 01:22 AM

Seen: 1472 times

Last Updated: Apr 19, 2012 at 06:56 AM