Random.Range never reach max?

What do you think would happen in this code?

using UnityEngine;
using System.Collections;

public class RandomRangeTest : MonoBehaviour
{
    void Update ()
    {
        int test = Random.Range (0, 3);
        if (test == 3)
            print ("I was wrong");
        else
            print ("Why it never reachs 3?");
    }
}

Random.Range(0, 3); will return one of the three values : 0 - 1 - 2 if the variable is an int.

Here : Unity - Scripting API: Random.Range
Int is exclusive, float is inclusive.

1 Like

Thx… I checked that but I didn’t notice the difference between float and int. At least it’s handy when you use it for index.