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
Collection Marker (Flowgraph Node)Custom Lua Command (Flowgraph Node)Get Object Field (Flowgraph Node)Get Player Vehicle ID (Flowgraph Node)Get Point on Decalroad (Flowgraph Node)Show/Hide Object (Flowgraph Node)ID by Name (Flowgraph Node)Keep Prefab (Flowgraph Node)Particle Emitter (Flowgraph Node)Point on Decalroad (Flowgraph Node)Raceline Parking (Flowgraph Node)Raycast (Flowgraph Node)Parking Markers / Rect Marker (Flowgraph Node)Reload Collision (Flowgraph Node)Reload Nav Graph (Flowgraph Node)Remove Prefab (Flowgraph Node)Reset Prefab (Flowgraph Node)Set Object Field (Flowgraph Node)Sevensegment Display (Flowgraph Node)Single Marker (Flowgraph Node)Spawn Light / SpotLight (Flowgraph Node)Spawn Prefab (Flowgraph Node)Spawn TSStatic (Flowgraph Node)Store Statics (Flowgraph Node)Track Prefab (Flowgraph Node)

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 Extensionsflowgraphnodesscene

Spawn Prefab (Flowgraph Node)

- **Node Name:** `Spawn Prefab`

Overview

  • Node Name: Spawn Prefab
  • Category: (once behavior)
  • File: extensions/flowgraph/nodes/scene/spawnPrefab.lua

Creates and manages a prefab in the scene. Supports .prefab.json and legacy .prefab formats. Spawns once and persists until reset or execution stop.

Pin Schema

Input Pins

PinTypeDescription
flowflowStandard inflow
resetVehflow (impulse)Resets vehicles inside this prefab to spawn positions
pathstringPath to the prefab file
namestring(Hidden) Custom prefab object name
posvec3Position to spawn the prefab
useGlobalTranslationbool(Hidden) Use global translation (default true)
silentbool(Hidden) Suppress file-not-found errors

Output Pins

PinTypeDescription
flowflowStandard outflow
createdflow (impulse)Fires when prefab is created
idnumberScene tree ID of the spawned prefab
origVehIdnumberPlayer vehicle ID before spawn (spawning prefabs with vehicles switches the active vehicle)
successbool(Hidden) Whether the prefab loaded successfully

Behavior

  • work() - Each frame with flow:
    • Spawns the prefab on first trigger (once behavior).
    • On resetVeh impulse, restores all vehicle positions within the prefab.
    • Sets created impulse and success output on spawn.
  • createObject() - Resolves the file path (trying .prefab and .prefab.json extensions), calls spawnPrefab(), adds to MissionGroup, and registers with the prefab module.

How It Works

  1. Captures the current player vehicle ID before spawning (since prefab vehicles may steal focus).
  2. Resolves the prefab path using mgr:getRelativeAbsolutePath() with fallback extensions.
  3. Calls the engine spawnPrefab(name, file, pos, rot, scale, useGlobalTranslation).
  4. The spawned object is flagged canSave = false and added to MissionGroup.
  5. Registers with mgr.modules.prefab:addPrefab() for lifecycle tracking.
  6. On cleanup, the objects list is cleared (prefab module handles actual deletion).

Example Usage

-- Spawn a traffic prefab at the origin:
-- path = "levels/west_coast_usa/scenarios/traffic_setup.prefab.json"
-- pos = {0, 0, 0}

Key Dependencies

  • spawnPrefab(name, file, pos, rot, scale, globalTrans) - engine function
  • self.mgr.modules.prefab:addPrefab() - registers prefab for lifecycle management
  • self.mgr.modules.prefab:restoreVehiclePositions() - resets vehicles in prefab

Additional Methods

C:_executionStopped()

Called when graph execution stops. Used for cleanup.

C:clearObjects()

Node method.

C:destroy()

Destroys the node and cleans up any created objects.

C:init(mgr, ...)

Initializes the node, setting up pins and default properties.

Parameters:

  • mgr
  • ...

C:onClientEndMission()

Cleanup callback when the mission/level ends.

C:postInit()

Called after initialization is complete for additional setup.


See Also

  • Collection Marker (Flowgraph Node) - Related reference
  • Custom Lua Command (Flowgraph Node) - Related reference
  • Get Object Field (Flowgraph Node) - Related reference
  • FlowGraph Guide - Guide

Spawn Light / SpotLight (Flowgraph Node)

- **Node Name:** `SpotLight`

Spawn TSStatic (Flowgraph Node)

- **Node Name:** `Spawn TSStatic`

On this page

OverviewPin SchemaInput PinsOutput PinsBehaviorHow It WorksExample UsageKey DependenciesAdditional MethodsC:_executionStopped()C:clearObjects()C:destroy()C:init(mgr, ...)C:onClientEndMission()C:postInit()See Also