Helix/Random
Random helpers for integers, floats and angle jittering.
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): numbergetFloat
Returns a random floating-point number between
from and to.getFloat(from: number, to: number): numbergetAngle
Returns a random angle in degrees around
directionDegrees within cone.getAngle(directionDegrees: number, cone: number): numberExamples #
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°