Prefab Module
Flowgraph module that manages prefab lifecycle-spawning, tracking, collision/navgraph reloading, vehicle extraction, and cleanup. Ensures all spawned prefabs are properly deleted when the flowgraph st
Flowgraph module that manages prefab lifecycle-spawning, tracking, collision/navgraph reloading, vehicle extraction, and cleanup. Ensures all spawned prefabs are properly deleted when the flowgraph stops, with collision and navgraph reloads as needed.
Module Properties
| Property | Value | Description |
|---|---|---|
moduleOrder | 50 | Mid-range initialization order |
Class Methods
Lifecycle
| Method | Description |
|---|---|
C:init() | Initializes prefabs, sortedIds, flags tables; calls clear() |
C:clear() | Clears all tracked prefabs, flags, and sorted ID list |
C:afterTrigger() | Reloads collision (be:reloadCollision()) and/or navgraph (map.reset()) if flagged |
C:executionStopped() | Deletes all non-kept prefabs, reloads collision/navgraph if any contained them |
Prefab Spawning & Tracking
| Method | Description |
|---|---|
C:spawnPrefab(fileName) | Spawns a prefab from file at origin, adds to MissionGroup, returns ID |
C:addPrefab(id, moreData) | Registers an existing prefab: finds children by type, stores vehicle transforms, flags collision/navgraph reloads |
C:getPrefab(id) | Returns tracked prefab data or empty table |
C:deletePrefab(id, force) | Deletes prefab unless marked dontDelete (force overrides); handles vehicle unpacking |
Vehicle Management
| Method | Description |
|---|---|
C:originalVehicleTransforms(data) | Records position/rotation/up for all vehicles in a prefab; registers them with vehicle module |
C:restoreVehiclePositions(id) | Resets all vehicles in a prefab to their original transforms |
C:getVehicleIdsForPrefab(id) | Returns sorted list of vehicle IDs contained in a prefab |
Prefab Options
| Method | Description |
|---|---|
C:setKeepPrefab(id, keep) | Marks a prefab to survive flowgraph stop (dontDelete flag) |
C:setUnpackVehiclesBeforeDeletion(id, set) | Marks prefab to extract vehicles to MissionGroup before deletion |
C:unpackPrefabAndDelete(id, obj) | Explodes prefab, moves vehicles to MissionGroup with current transforms, deletes prefab group |
Usage Example
local prefabMod = mgr.modules.prefab
-- Spawn a prefab from file
local prefabId = prefabMod:spawnPrefab("levels/west_coast_usa/art/props/checkpoint.prefab.json")
-- Keep prefab after flowgraph stops
prefabMod:setKeepPrefab(prefabId, true)
-- Reset vehicles inside a prefab to original positions
prefabMod:restoreVehiclePositions(prefabId)
-- Get all vehicle IDs inside a prefab
local vehIds = prefabMod:getVehicleIdsForPrefab(prefabId)
-- Extract vehicles before deleting prefab
prefabMod:setUnpackVehiclesBeforeDeletion(prefabId, true)
prefabMod:deletePrefab(prefabId)Internal Details
findObjectsRecursivewalks SimSet/SimGroup/Prefab hierarchies to catalogue all objects by classfindAllObjectswarns about named objects in activity prefabs (except ignored classes) to prevent conflictscontainsColliderschecks TSStatic objects for non-"None"collisionTyperequiresNavgraphReloadchecks for BeamNGWaypoint (not excluded from map) and drivable DecalRoad objects- Collision/navgraph reloads are deferred via
flagsand handled inafterTrigger()or via level module during loading - Spawned prefabs have
canSave = falseto avoid serialization
See Also
- Flowgraph Action Module - Related reference
- Flowgraph AI Recording Module - Related reference
- Flowgraph Button Module - Related reference
- FlowGraph Guide - Guide
Mission Replay Module
Flowgraph module that manages mission replay recording and playback. Handles automatic recording during mission attempts, replay file management (deletion by count or size), metadata generation, and c
Thread Module
Flowgraph module for inter-flowgraph messaging and child project management. Enables flowgraph managers to send/receive messages and spawn child flowgraph projects that communicate back via the thread