v0.7.1 (build 925)

Random helpers for integers, floats, and angles.

Import #

import * as Random from 'Helix/Random';

Functions #

getInt
Returns a random integer in the inclusive range [from, to].
getInt(from: number, to: number): number
getFloat
Returns a random floating-point number between from and to.
getFloat(from: number, to: number): number
getAngle
Returns a random angle in degrees around directionDegrees within cone.
getAngle(directionDegrees: number, cone: number): number

Examples #

Generate a random dice roll, a normalized float for interpolation, and a jittered angle for directional spread. getAngle is particularly useful for particle effects or randomized spawn directions.

import * as Random from 'Helix/Random';

const die = Random.getInt(1, 6);
const t = Random.getFloat(0, 1);
const aim = Random.getAngle(90, 30); // around east ± 15°