API ReferenceGE Extensionsflowgraphnodesvehicleai
AI Traffic
- **Node Name:** `AI Traffic`
Overview
- Node Name:
AI Traffic - Category:
once_p_duration - File:
extensions/flowgraph/nodes/vehicle/ai/traffic.lua
Sets a vehicle's AI to drive following traffic rules. Note: This only sets the individual vehicle's AI mode - it does not enable the traffic management system.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
aiVehId | number | Vehicle ID to set to traffic AI mode. Uses player vehicle if empty. |
Internals
Key Methods
| Method | Description |
|---|---|
workOnce() | Resolves the vehicle and queues ai.setMode("traffic") on it. |
How It Works
workOnce()fires once when the node receives flow.- Resolves the vehicle from
aiVehIdor falls back to the player vehicle. - Sends
ai.setMode("traffic")to the vehicle's Lua VM. - The vehicle AI then follows traffic rules (speed limits, signals, lanes) but operates independently of the traffic management system.
Important: This node uses
ai.setMode()(notai.setState()) - a slightly different API than other AI nodes.
Usage Example
-- Flowgraph:
-- [Spawn Vehicle] → vehId → [AI Traffic] → continues...
-- Equivalent vehicle-side command:
ai.setMode("traffic")
-- To also enable the full traffic system, use:
-- gameplay_traffic.setupTraffic()Key Dependencies
ai.setMode("traffic")- vehicle-side AI mode setter
See Also
- AI Parameters (Flowgraph Node) - Related reference
- AI Arrive (Flowgraph Node) - Related reference
- AI Chase (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide