In Unity C# the method is as follows
Random.Range(minVal, maxVal);
See Unity Documentation – Random
The method will accept either integer or float arguments. If using ints minVal
is inclusive and maxVal
is exclusive of the returned random value. In your case it would be:
Random.Range(1,4);
Instead of Next(1,4)
.
If using floats, for example
Random.Range(1.0F, 3.5F);
The return value is also a float, minVal
and maxVal
are inclusive in this case.