API ReferenceGE Extensionsflowgraphnodesutil Route Distance (Flowgraph Node)
- **Node Name:** `Route Distance`
- Node Name:
Route Distance
- Category:
repeat_instant
- File:
extensions/flowgraph/nodes/util/closestPath.lua
Finds the approximate remaining distance along a navgraph route from a tracked position. Supports both two-point and multi-waypoint routes.
| Pin | Type | Description |
|---|
setRoute | flow (impulse) | Sets/recalculates the route |
trackedPos | vec3 | The position being tracked along the route |
posA | vec3 | First endpoint (shown when waypoints mode is off) |
posB | vec3 | Second endpoint (shown when waypoints mode is off) |
waypoints | table | Ordered waypoint positions (shown when waypoints mode is on) |
| Pin | Type | Description |
|---|
dist | number | Distance remaining to the end of the route (-1 if invalid) |
| Method | Description |
|---|
init() | Initializes the waypoint toggle |
work() | Sets route on impulse, tracks position, outputs distance |
drawCustomProperties() | ImGui checkbox to toggle waypoints mode |
updatePins() | Swaps between posA/posB pins and waypoints pin |
| Property | Type | Description |
|---|
waypoint | bool | Toggle between two-point and multi-waypoint mode |
- When
setRoute is triggered, creates a new gameplay/route/route instance.
- In two-point mode, calls
route:setupPathMulti({posB, posA}) (note reversed order).
- In waypoints mode, calls
route:setupPathMulti(waypoints).
- On each frame, if
trackedPos has changed, calls route:trackPosition(trackedPos).
- Outputs
route.path[1].distToTarget as the remaining distance.
-- Create a route and track distance:
local route = require('/lua/ge/extensions/gameplay/route/route')()
route:setupPathMulti({vec3(startPos), vec3(endPos)})
-- Each frame:
route:trackPosition(vec3(currentPos))
local remaining = route.path[1].distToTarget
-- In flowgraph:
-- [Set Route impulse] → [Route Distance] → dist → [Compare/Display]
-- ↑ posA, posB ↑ trackedPos (from vehicle)
gameplay/route/route - route calculation along navgraph
route:setupPathMulti() - multi-waypoint route setup
route:trackPosition() - updates position along route