API ReferenceGE Extensionsflowgraphnodesvehicleai Follow Decalroad
- **Node Name:** `Follow Decalroad`
- Node Name:
Follow Decalroad
- File:
extensions/flowgraph/nodes/vehicle/ai/simpleFollowDecalroad.lua
- Behaviour: duration
Converts a DecalRoad object into a ScriptAI path and drives a vehicle along it. Provides progress tracking and start/stop control.
| Pin | Type | Description |
|---|
flow | flow | Inflow for this node. |
start | flow | Starts the AI when flow is received. |
stop | flow | Stops the AI when flow is received. |
roadName | string | Name of the DecalRoad object in the scene tree. |
vehId | number | Vehicle ID. Uses player vehicle if empty. |
loopCount | number | Number of loops (-1 = infinite, hidden). |
| Pin | Type | Description |
|---|
flow | flow | General outflow. |
active | flow | Outputs flow while the AI is actively following. |
finished | flow | Outputs flow when the AI finishes the path. |
progress | number | Relative progress from 0 to 1. |
| Method | Description |
|---|
init() | Sets defaults: speed=5, loopMode="startReset". |
loadRecording() | Reads DecalRoad node positions, computes distances, generates path with timing based on data.speed. |
play() | Loads path and starts ai.startFollowing(). |
stop() | Sends ai.stopFollowing() and clears active state. |
onVehicleSubmitInfo(id, info) | Receives progress updates - scriptTime / endScriptTime for progress, nil info = finished. |
work() | Dispatches start/stop impulses. |
| Property | Default | Description |
|---|
speed | 5 | Speed (m/s) used to calculate waypoint timestamps. |
loopMode | "startReset" | Loop reset mode for the ScriptAI. |
renderDebug | false | Draw path debug visualization. |
loadRecording() iterates over the DecalRoad's nodes via road:getNodeCount() and road:getNodePosition(i).
- Accumulates segment distances to compute timing:
t = distance / speed.
- Sets the first waypoint's
dir (direction to second point) and up (hardcoded Z-up).
play() sends the path to ai.startFollowing() with loop settings.
- Progress is tracked via
onVehicleSubmitInfo callback - scriptTime / endScriptTime.
-- Path generation from DecalRoad:
local road = scenetree.findObject("myRoad")
local path = {}
local dist = 0
for i = 0, road:getNodeCount() - 2 do
local pos = vec3(road:getNodePosition(i))
table.insert(path, {x=pos.x, y=pos.y, z=pos.z, t=dist/speed})
dist = dist + (vec3(road:getNodePosition(i+1)) - pos):length()
end
-- Flowgraph:
-- [Start Button] → start → [Follow Decalroad (roadName="race_track", speed=10)]
-- → progress → [Progress Bar]
-- → finished → [Race Complete]
scenetree.findObject() - resolves the DecalRoad by name
road:getNodeCount() / road:getNodePosition() - reads road geometry
ai.startFollowing() / ai.stopFollowing() - vehicle-side ScriptAI
onVehicleSubmitInfo hook - progress tracking from vehicle VM