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

ArgsReturnsNotes
(int, int)intInteger range; equivalent to System.Random.Next(min, max).
(decimal, decimal)decimalDecimal range; uses NextDouble internally for [0, 1) scaling.
(number, number)numberFallback 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.

Docs last synced: 2026-07-08
Screenshot viewer