API ReferenceGE Extensionsflowgraphnodesutil
Get Navgraph Route
- **Node Name:** `Get Navgraph Route`
Overview
- Node Name:
Get Navgraph Route - Category:
once_instant - File:
extensions/flowgraph/nodes/util/routePointToPoint.lua
Finds a navgraph route between two world positions. Snaps each position to the closest navgraph node, then computes a path using the map pathfinder.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
posA | vec3 | - | Start position |
posB | vec3 | - | Finish position |
legalRoute | bool | true | If true, respect legal road directions (hidden) |
Output Pins
| Pin | Type | Description |
|---|---|---|
navgraphRoute | table (navgraphPath) | Array of waypoint names forming the route |
Internals
Key Methods
| Method | Description |
|---|---|
workOnce() | Finds closest navgraph nodes to each position and computes a path |
Route Calculation
- For each position (
posA,posB), callsmap.findClosestRoad()to get the two nearest nodes. - Selects the closer of the two nodes by squared distance comparison.
- Calls
map.getPath(nodeA, nodeB, nil, penalty)where penalty is1000for legal routes or1for unrestricted.
Legal vs Unrestricted Routes
- Legal route (
legalRoute = true): Uses a high penalty (1000) for wrong-way traversal, effectively forcing legal directions. - Unrestricted (
legalRoute = false): Uses penalty of 1 so wrong-way roads are treated the same as normal.
How It Works
- Converts
posAandposBfrom tables to vec3. - Finds the nearest navgraph road nodes for both positions.
- Picks the closer node of the two candidates at each end.
- Runs the map pathfinder between the two nodes.
- Outputs the resulting waypoint array, suitable for AI driving or route display.
Usage Example
-- Find a legal route between two positions:
-- posA = {100, 200, 30} -- start world position
-- posB = {500, 800, 35} -- finish world position
-- legalRoute = true
-- Output: {"wp_001", "wp_002", "wp_003", ...}
-- Use with AI Follow Waypoints node:
-- Connect navgraphRoute output → AI Follow Waypoints navgraphPath inputKey Dependencies
map.findClosestRoad()- finds nearest navgraph road from a positionmap.getPath()- navgraph A* pathfindermap.getMap().nodes- navgraph node data
See Also
- Route Distance (Flowgraph Node) - Related reference
- Closest Road (Flowgraph Node) - Related reference
- Custom Lua (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide