04-09-2025 08:10 AM
For those that are used to Unity might recognize this.
// returns a random whole number between min (inclusive) and max (exclusive)
randomRange(min: number, max: number) {
return Math.floor(min + Math.random() * (max - min));
}
// returns a float between min (inclusive) and max (exclusive)
randomRange(min: number, max: number) {
return min + Math.random() * (max - min);
}
04-24-2025 02:45 PM
Here is an updated version of the helper function
RandomRange(min: number, max: number, isFloat: boolean) {
if (isFloat) return min + Math.random() * (max - min);
else return Math.floor(min + Math.random() * (max - min));
}