RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Flowgraph Base ModuleFlowgraph Base NodeFlowgraph Base State NodeFlowgraph Node BuilderFlowgraph GraphFlowgraph Group HelperFlowgraph LinkFlowgraph ManagerNew Node TemplateFlowgraph PinFlowgraph States ManagerFlowgraph UtilsFlowgraph Variable Storage
Align For CouplingApply Velocity to VehicleBoost VehicleSet Vehicle ColorsCustom Parts Config ProviderEnter VehicleFlip UprightFreeze VehicleGenerate License PlateGet Vehicle ActiveGet Electrics ValueGet GearboxmodeGet Powertrain DataGravity ForceDistance From GroundHas Coupler TagIs CoupledIs Player UsableKeep VehicleMove Vehicle ToOn Cannon FiredOn Vehicle DestroyedOn Vehicle ResetOn Vehicle SpawnedOn Vehicle SwitchedPlayer UsableRandom Config ProviderRecover In PlaceRemove VehicleTimeline ReplaySet Vehicle ActiveSet Gearbox ModeSet IgnitionSet License PlateSet LightbarSet LightsShift to Gear IndexSpawn VehicleVehicle StatesTeleport To Last RoadToggle Vehicle ControlsMove To ShowroomVehicle TouchProps TouchStatic Object TouchTrack VehicleTrailer Respawn ControlVehicle Config ProviderGet Vehicle DataGet Vehicle DataGet Vehicle BoundsVehicle PingGet Vehicle Wheel Center

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsflowgraphnodesvehicle

Spawn Vehicle

- **Node Name:** `Spawn Vehicle`

Overview

  • 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 Schema

Input Pins

PinTypeDefaultDescription
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)falseReplace current player vehicle instead of spawning new
keepCamerabool (hidden)trueKeep camera on current vehicle (don't auto-switch)
keepVehiclebool (hidden)trueDon't delete vehicle when project stops
keepOnResetbool (hidden)trueDon't delete vehicle when node resets

Output Pins

PinTypeDescription
flowflowContinues once vehicle is loaded
loadedflow (impulse)Fires once after vehicle is fully loaded
vehIdnumberID of the spawned vehicle

Legacy Pin Mapping

  • out.objectId → vehId
  • in.replaceCurrent → replacePlayer
  • in.keepCurrent → keepCamera
  • in.dontDelete → keepVehicle

Internals

State Machine

StateDescription
1Spawning - builds options, calls spawn/replace, transitions to state 2
2Waiting - polls mgr.modules.vehicle:getVehicle(id).ready until vehicle is loaded
3Loaded - fires loaded impulse, sets flow and vehId outputs, transitions to state 4
4Done - keeps flow true, clears loaded impulse

Key Methods

MethodDescription
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

Spawning Logic (State 1)

  1. Generates a name if none provided.
  2. Loads model and parses config key (strips .pc extension).
  3. 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.
  4. Creates options table with config, paint, license text, name, position, rotation.
  5. Calls sanitizeVehicleSpawnOptions() to validate.
  6. Either core_vehicles.replaceVehicle() or core_vehicles.spawnNewVehicle().
  7. Registers with mgr.modules.vehicle:addVehicle().

Usage Example

-- 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)

Key Dependencies

  • 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

Previously Undocumented (Added by Audit)

  • C:getCmd(action) - Function handling getCmd logic

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

Shift to Gear Index

- **Node Name:** `Shift to Gear Index`

Vehicle States

- **Node Name:** `Vehicle States`

On this page

OverviewPin SchemaInput PinsOutput PinsLegacy Pin MappingInternalsState MachineKey MethodsSpawning Logic (State 1)Usage ExampleKey DependenciesPreviously Undocumented (Added by Audit)See Also