API Reference GE Extensions flowgraph nodes vehicle Spawn Vehicle - **Node Name:** `Spawn Vehicle`
Node Name: Spawn Vehicle
Category: (default)
File: extensions/flowgraph/nodes/vehicle/spawnVehicle.lua
Spawns a vehicle in the world with full configuration support including model, config, position, rotation, color, license plate, and various behavioral options. Uses a multi-frame state machine to handle async spawning.
Pin Type Default Description flowflow - Triggers the spawn resetflow (impulse, hidden) - Removes the vehicle and resets the node modelstring 'pickup'Vehicle model key configstring/table 'vehicles/pickup/d15_4wd_A.pc'Vehicle config key or table posvec3 - (Optional) Spawn world position rotquat - (Optional) Spawn world rotation licenseTextstring (hidden) 'Flow'(Optional) License plate text colorcolor/string (hidden) {0.25,0.25,0.25,0.5}(Optional) Vehicle color or paint name randomColorbool (hidden) - If true, picks random paint from available colors namestring (hidden) nil (Optional) Object name in scene tree replacePlayerbool (hidden) false Replace current player vehicle instead of spawning new keepCamerabool (hidden) true Keep camera on current vehicle (don't auto-switch) keepVehiclebool (hidden) true Don't delete vehicle when project stops keepOnResetbool (hidden) true Don't delete vehicle when node resets
Pin Type Description flowflow Continues once vehicle is loaded loadedflow (impulse) Fires once after vehicle is fully loaded vehIdnumber ID of the spawned vehicle
out.objectId → vehId
in.replaceCurrent → replacePlayer
in.keepCurrent → keepCamera
in.dontDelete → keepVehicle
State Description 1 Spawning - builds options, calls spawn/replace, transitions to state 22 Waiting - polls mgr.modules.vehicle:getVehicle(id).ready until vehicle is loaded3 Loaded - fires loaded impulse, sets flow and vehId outputs, transitions to state 44 Done - keeps flow true, clears loaded impulse
Method Description init()Sets initial state to 1 postInit()Configures color pin for vehicle color setup _executionStarted()Resets all state _executionStopped()Clears spawned object reference work()Runs the state machine - handles reset, spawning, waiting, and output drawMiddle()Shows current state and vehicle ID in the node
Generates a name if none provided.
Loads model and parses config key (strips .pc extension).
Resolves paint color:
If randomColor is true: picks from model's available paints (skips Police/Service vehicles).
If color is a string: looks up named paint from model data.
If color is a table with baseColor or [4]: uses as raw paint data.
Creates options table with config, paint, license text, name, position, rotation.
Calls sanitizeVehicleSpawnOptions() to validate.
Either core_vehicles.replaceVehicle() or core_vehicles.spawnNewVehicle().
Registers with mgr.modules.vehicle:addVehicle().
-- In a flowgraph - spawn a pickup at a specific location:
-- [Vec3 Position] → [Spawn Vehicle].pos
-- [String: "pickup"] → [Spawn Vehicle].model
-- [String: "vehicles/pickup/d15_4wd_A.pc"] → [Spawn Vehicle].config
-- [Trigger] → [Spawn Vehicle].flow
-- [Spawn Vehicle] → (loaded) → [Configure Vehicle]
-- → (vehId) → [Set AI Mode]
-- Direct Lua equivalent:
local options = {
config = 'vehicles/pickup/d15_4wd_A.pc' ,
licenseText = 'FLOW' ,
vehicleName = 'myVehicle' ,
pos = vec3 ( 0 , 0 , 100 ),
}
options = sanitizeVehicleSpawnOptions ( 'pickup' , options)
local veh = core_vehicles. spawnNewVehicle ( 'pickup' , options)
core_vehicles.spawnNewVehicle(model, options) - spawns a new vehicle
core_vehicles.replaceVehicle(model, options) - replaces the player vehicle
sanitizeVehicleSpawnOptions(model, options) - validates spawn options
core_vehicles.getModel() / core_vehicles.getConfig() - vehicle metadata
mgr.modules.vehicle:addVehicle() - registers vehicle with flowgraph manager
createVehiclePaint() - creates paint data from color values
C:getCmd(action) - Function handling getCmd logic