API ReferenceGE Extensionsflowgraphnodesutil
Waypoints Distance (Flowgraph Node)
- **Node Name:** `Waypoints Distance`
Overview
- Node Name:
Waypoints Distance - Category:
repeat_instant - File:
extensions/flowgraph/nodes/util/distanceRemaining.lua
Calculates the remaining distance from a vehicle to the end of a waypoint path, and determines whether the vehicle is traveling in the correct direction.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
alwaysUpdate | flow (hidden) | When active, forces distance recalculation every frame regardless of velocity |
vehId | number | ID of the tracked vehicle |
waypoints | table | Array of vec3 positions defining the path |
Output Pins
| Pin | Type | Description |
|---|---|---|
distLeft | number | Remaining distance along the waypoint path |
rightWay | bool | Whether the vehicle is traveling in the correct direction |
goingRightWay | flow | Flow when vehicle is going the right way |
goingWrongWay | flow | Flow when vehicle is going the wrong way |
Internals
Key Methods
| Method | Description |
|---|---|
work() | Finds nearest path segment, calculates remaining distance, determines travel direction |
Direction Detection
The node uses a velocity threshold of 0.50 to determine direction. If the vehicle speed is below this threshold, it is considered "going the right way" by default. When above the threshold, the dot product of the path direction vector and vehicle velocity is used.
How It Works
- Iterates all waypoint line segments and finds the one closest to the vehicle position using
distanceToLineSegment. - Projects the vehicle onto that segment using
xnormOnLineto find the exact position along the segment. - Sums the distance from the projected point to the end of the current segment, plus all subsequent segment lengths.
- Checks direction by comparing the vehicle velocity vector against the path direction (dot product > 0 = right way).
- When
alwaysUpdateis not set and the vehicle is below the speed threshold, the last computed distance is re-used.
Usage Example
-- In a flowgraph, connect waypoints from a path node:
-- [Get Waypoints] → waypoints → [Waypoints Distance] → distLeft → [Display HUD]
-- vehId ←── [Player Vehicle ID]
-- → goingWrongWay → [Show Wrong Way Warning]Key Dependencies
map.objects- provides vehicle position and velocity datavec3math -distanceToLineSegment,xnormOnLine,dot
Previously Undocumented (Added by Audit)
- Input Pin:
goingRigthWay(any)
See Also
- Route Distance (Flowgraph Node) - Related reference
- Closest Road (Flowgraph Node) - Related reference
- Custom Lua (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide