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]

Your code doesn't give any errors?

@Noran: no, look in the docs. It's Random.Range. @chiggafoo: define your variable types. Also, format code when you post it.

1 Answer

1

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.

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