API ReferenceGE Extensionsflowgraphnodesutil
Random Quaternion
- **Node Name:** `Random Quaternion`
Overview
- Node Name:
Random Quaternion - Category:
repeat_instant - File:
extensions/flowgraph/nodes/util/randomQuaternion.lua
Generates a random quaternion rotation by interpolating between min/max Euler angles on each axis. Outputs a new random rotation every frame.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
xMinAngle | number | 0 | Minimum angle for X axis, in degrees (hardcoded) |
xMaxAngle | number | 0 | Maximum angle for X axis, in degrees (hardcoded) |
yMinAngle | number | 0 | Minimum angle for Y axis, in degrees (hardcoded) |
yMaxAngle | number | 0 | Maximum angle for Y axis, in degrees (hardcoded) |
zMinAngle | number | 0 | Minimum angle for Z axis, in degrees (hardcoded) |
zMaxAngle | number | 360 | Maximum angle for Z axis, in degrees (hardcoded) |
Output Pins
| Pin | Type | Description |
|---|---|---|
quaternion | quat | The random quaternion value (as table {x,y,z,w}) |
Internals
Key Methods
| Method | Description |
|---|---|
work() | Generates a random quaternion from per-axis Euler angle ranges each frame |
Quaternion Construction
- For each axis,
lerpinterpolates between min and max radian values usingmath.random(). - Builds the quaternion by sequential multiplication:
quatFromEuler(x,0,0) * quatFromEuler(0,y,0) * quatFromEuler(0,0,z). - Outputs the result as a table via
q:toTable().
How It Works
- Each frame, random angles are picked within the min/max range for X, Y, and Z.
- Angles are converted from degrees to radians using
math.rad(). - Three axis-aligned quaternions are multiplied together to form the final rotation.
- Default setup (only Z: 0–360°) produces random yaw rotations with no pitch or roll.
Usage Example
-- Random yaw only (default):
-- zMinAngle = 0, zMaxAngle = 360
-- All other angles = 0
-- Output: random rotation around Z axis
-- Full random orientation:
-- xMinAngle = 0, xMaxAngle = 360
-- yMinAngle = 0, yMaxAngle = 360
-- zMinAngle = 0, zMaxAngle = 360
-- Limited tilt (±15° pitch, random yaw):
-- xMinAngle = -15, xMaxAngle = 15
-- yMinAngle = 0, yMaxAngle = 0
-- zMinAngle = 0, zMaxAngle = 360Key Dependencies
quatFromEuler()- creates a quaternion from Euler angleslerp()- linear interpolation helper
See Also
- Route Distance (Flowgraph Node) - Related reference
- Closest Road (Flowgraph Node) - Related reference
- Custom Lua (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide