API ReferenceGE Extensionsflowgraphnodesutil
Random Vector
- **Node Name:** `Random Vector`
Overview
- Node Name:
Random Vector - Category:
repeat_instant - File:
extensions/flowgraph/nodes/util/randomVector.lua
Generates a random 3D vector (not normalized) by independently randomizing each axis within min/max bounds. Outputs a new vector every frame.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
xMin | number | -1 | Minimum value for the X axis (hardcoded) |
xMax | number | 1 | Maximum value for the X axis (hardcoded) |
yMin | number | -1 | Minimum value for the Y axis (hardcoded) |
yMax | number | 1 | Maximum value for the Y axis (hardcoded) |
zMin | number | -1 | Minimum value for the Z axis (hardcoded) |
zMax | number | 1 | Maximum value for the Z axis (hardcoded) |
Output Pins
| Pin | Type | Description |
|---|---|---|
vector | vec3 | The random vector value (as table {x,y,z}) |
Internals
Key Methods
| Method | Description |
|---|---|
work() | Generates a random vec3 from per-axis min/max ranges |
Vector Construction
Each axis uses lerp(min, max, math.random()) to produce a uniformly distributed random value within the range. The result is output as a table {x, y, z}.
How It Works
- Each frame, three independent random values are generated (one per axis).
lerplinearly interpolates between min and max usingmath.random()(0–1).- The vector is not normalized - its magnitude depends on the input ranges.
- Output as a plain table
{x, y, z}on thevectorpin.
Usage Example
-- Random position in a 10x10x0 area (flat ground):
-- xMin = -5, xMax = 5
-- yMin = -5, yMax = 5
-- zMin = 0, zMax = 0
-- Random offset for spawning objects:
-- xMin = -2, xMax = 2
-- yMin = -2, yMax = 2
-- zMin = 0, zMax = 5Key Dependencies
lerp()- 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