x


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

chiggafoo gravatar image

chiggafoo
74 36 26 27

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

SirMacJefferson gravatar image

SirMacJefferson
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

By RSS:

Answers

Answers and Comments

Topics:

x4137
x1045
x176

asked: Mar 03, 2012 at 01:22 AM

Seen: 1410 times

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