unity Math random code example

Example 1: random number generator unity

int num = Random.Range(min, max);

Example 2: unity random int

//If you use Int in the Random.Range() then it will
	//return an Int
	public int RanTimerHigh = 10;
    public int RanTimerLow = 1;

    void Start()
    {
        int RandomInt = Random.Range(RanTimerLow, RanTimerHigh);
    }

Example 3: unity random float

// To get a random float between two values:
 float number = Random.Range(0.0f, 3.0f);

Example 4: unity random number

Random.Range(-10.0f, 10.0f);

Example 5: random in unity

// random int
int num = Random.Range(min/*int*/, max/*int*/);
 // random float
float num2 = Random.Range(min/*float*/, max/*float*/);

Example 6: unity random

var RandomValue = UnityEngine.Random.Range(min,max);