API ReferenceGE Extensionsflowgraphnodesvehicleai
AI Arrive
- **Node Name:** `AI Arrive`
Overview
- Node Name:
AI Arrive - Category:
once_f_duration - File:
extensions/flowgraph/nodes/vehicle/ai/arrive.lua
Drives a vehicle toward a target waypoint using AI manual mode. The node monitors distance and velocity to determine arrival, then optionally disables the AI. Has a duration state that transitions from inactive → started → finished.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
aiVehId | number | - | Vehicle ID to drive (uses player vehicle if empty) |
waypointName | string | - | Name of the target waypoint |
checkDistance | number | 1 | Arrival distance threshold; 0 = use waypoint radius (hidden) |
checkVelocity | number | 0.1 | Vehicle must be slower than this to count as arrived (hidden, hardcoded) |
Output Pins
| Pin | Type | Description |
|---|---|---|
distance | number | Current distance to the waypoint center (hidden) |
Internals
Key Methods
| Method | Description |
|---|---|
init() | Sets initial state, enables autoDisableOnArrive |
onNodeReset() | Resets command sent flag and duration state |
_executionStopped() | Calls onNodeReset() |
getVeh() | Resolves vehicle by ID or player vehicle |
work() | Sends AI command (once), monitors distance/velocity for arrival |
Arrival Detection
- Gets the vehicle's front position via corner positions interpolation.
- Computes distance to the waypoint node position.
- Vehicle is "arrived" when:
- Distance <
checkDistance(or waypoint radius if 0) - Velocity <
checkVelocity(frommap.objects[vehID].vel)
- Distance <
- On arrival, sets duration state to
finishedand optionally disables AI.
AI Command
The command is sent only once (self.sentCommand flag):
ai.setState({mode = "manual"})
ai.setTarget("waypointName")How It Works
- First frame: sends
ai.setState({mode = "manual"})andai.setTarget()to the vehicle. - Each subsequent frame: measures distance from vehicle front to waypoint.
- When close enough and slow enough, transitions to
finished. - If
autoDisableOnArriveis true (default), disables AI on arrival. - Once finished, the node stops processing (early return).
Usage Example
-- Drive AI to a specific waypoint:
-- aiVehId = vehicleId
-- waypointName = "wp_finish_line"
-- checkDistance = 2 (meters)
-- checkVelocity = 0.5 (m/s, nearly stopped)
-- Chain with duration state:
-- Connect to nodes that react to 'finished' duration state
-- The node's flow output continues after arrivalKey Dependencies
map.getMap().nodes- waypoint node data (position, radius)map.objects- vehicle tracking data (velocity)ai.setState()/ai.setTarget()- vehicle AI commands
See Also
- AI Parameters (Flowgraph Node) - Related reference
- AI Chase (Flowgraph Node) - Related reference
- AI Directly To (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide