RandomRange
Returns a uniformly distributed random value in the half-open range [min, max). The result can equal min but will never equal max. The random stream is seeded per session, so the same sequence replays from a saved snapshot.
Category: Math Returns: matches the input type; see overloads.
Signature
RandomRange(min, max)
Overloads
| Args | Returns | Notes |
|---|---|---|
(int, int) | int | Integer range; equivalent to System.Random.Next(min, max). |
(decimal, decimal) | decimal | Decimal range; uses NextDouble internally for [0, 1) scaling. |
(number, number) | number | Fallback when arg types can’t be statically resolved (e.g. variable inputs). |
Examples
RandomRange(1, 6) // integer 1–5 (inclusive)
RandomRange(0.0, 10.0) // decimal in [0, 10)
RandomRange(minVal, maxVal) // variable bounds: routes through number overload
Notes
The max bound is exclusive. This matches Unity’s System.Random.Next(min, max) convention: the returned value can equal min but never max. For a session-level random decimal in [0, 1), see Random.