API ReferenceGE Extensionsflowgraphnodesvehicle
On Vehicle Spawned
- **Node Name:** `On Vehicle Spawned`
Overview
- Node Name:
On Vehicle Spawned - Category:
logic - File:
extensions/flowgraph/nodes/vehicle/onVehicleSpawned.lua
Triggers when a new vehicle is spawned in the world. Fires an impulse with the spawned vehicle's ID.
Pin Schema
Input Pins
| Pin | Type | Description |
|---|---|---|
flow | flow | Inflow for this node |
Output Pins
| Pin | Type | Description |
|---|---|---|
flow | flow (impulse) | Fires once when a vehicle is spawned |
vehId | number | ID of the vehicle that was spawned |
Legacy Pin Mapping
out.vehicleID→vehId
Internals
Key Methods
| Method | Description |
|---|---|
init() | Empty initialization |
_executionStarted() | Resets flag and info table |
onVehicleSpawned(id) | Hook - stores spawned vehicle ID and sets flag |
work() | If flag is set, outputs vehicle ID and fires impulse, then clears flag |
_afterTrigger() | Clears the flag for single-frame impulse |
How It Works
- The node subscribes to the
onVehicleSpawnedhook automatically. - When any vehicle is spawned,
onVehicleSpawned(id)stores the ID and sets a flag. - On the next
work()tick, the node outputs the ID and fires the flow impulse. - The flag is cleared to ensure the impulse lasts exactly one frame.
Usage Example
-- In a flowgraph - react to any vehicle spawn:
-- [On Vehicle Spawned] → (vehId) → [Set AI Mode / Configure Vehicle]
-- The engine hook:
-- onVehicleSpawned(vehicleId)Key Dependencies
onVehicleSpawnedengine hook - fires when a new vehicle object is created
See Also
- Align for Coupling (Flowgraph Node) - Related reference
- Apply Velocity to Vehicle (Flowgraph Node) - Related reference
- Boost Vehicle (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide