API ReferenceGE Extensionsflowgraphnodesvehicleai
AI Follow
- **Node Name:** `AI Follow`
Overview
- Node Name:
AI Follow - Category:
once_p_duration - File:
extensions/flowgraph/nodes/vehicle/ai/follow.lua
Sets a vehicle's AI to follow another vehicle with intentional contact disabled. Unlike chase mode, the AI will not attempt to ram the target.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
aiVehId | number | - | Vehicle ID to apply AI follow mode (uses player vehicle if empty) |
targetId | number | - | Vehicle ID of the vehicle to follow (defaults to player vehicle) |
Internals
Key Methods
| Method | Description |
|---|---|
workOnce() | Sets AI mode to "follow" and assigns the target vehicle |
Commands Sent
ai.setMode("follow")
ai.setTargetObjectID(targetId)How It Works
- Resolves the AI vehicle by
aiVehIdor defaults to the player vehicle. - Resolves the target by
targetIdor defaults to player vehicle ID. - Queues two Lua commands: set mode to "follow" and set target object ID.
- Executes once, then the AI continues following autonomously.
Follow vs Chase
| Mode | Contact | Behavior |
|---|---|---|
follow | Disabled | Trails the target at a safe distance |
chase | Enabled | Actively tries to ram the target |
Usage Example
-- Make vehicle 5 follow the player:
-- aiVehId = 5
-- targetId = (empty, defaults to player)
-- Convoy setup - vehicle 5 follows vehicle 3:
-- aiVehId = 5
-- targetId = 3Key Dependencies
ai.setMode("follow")- enables follow AI mode (no contact)ai.setTargetObjectID()- sets the vehicle to follow
See Also
- AI Parameters (Flowgraph Node) - Related reference
- AI Arrive (Flowgraph Node) - Related reference
- AI Chase (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide