A question about Random.Range

My goal is a randomly rotating asteroid. The solution is quiet ok, but I am wondering a little.
According to the reference, the min and max-values are inclusive. Therefore I would anticipate values between 0 and 2 for the temp variable. But it is just 0 and 1. And furthermore just the _rotation[cnt] with the index equal to temp gets an other value then zero…checked now some thing, typecasting the Random.Range(1,9) / 10; to float solves this problem. But this means the reference is wrong, because it says:

Or do I misunderstand something?

public class AsteroidRotation : MonoBehaviour {
	public float[] _rotation= new float[3];
	private int temp;
	// Use this for initialization
	void Start () {
	 temp = (int)Random.Range(0,2);
		Debug.Log(temp);
		for (int cnt = 0; cnt <3; cnt++){
			if (cnt == temp){
				_rotation[cnt] = Random.Range(1,20);
				Debug.Log("Cnt: " + cnt + " Random: " + _rotation[cnt] );
			}
			else {
				_rotation[cnt] = Random.Range(1,9) / 10;
				Debug.Log("Cnt: " + cnt + " Random: " + _rotation[cnt] );
			}
		
		}
	}
	
	// Update is called once per frame
	void Update () {
		
			
		transform.Rotate(_rotation[0]* Time.deltaTime,_rotation[1]* Time.deltaTime ,_rotation[2]* Time.deltaTime);
	}
}

No, according to the reference, the max value is exclusive for integers. http://unity3d.com/support/documentation/ScriptReference/Random.Range.html...you need to read farther down.

–Eric

oha, my bad :frowning:
But it is a little bit confusing to read this :slight_smile:

That’s known as an overload. Many functions have overloads, such as Physics.Raycast and so on, where the function does different things depending on the parameters you pass in. So, the docs have to list all the options.

–Eric

Thank you. I see, I have to learn very much about scripting and programming