Multi Spawn
Spawns groups of vehicles in configurable formations (road, grid, line). Handles vehicle selection from installed data with population-weighted randomization, paint assignment, and formation placement
Spawns groups of vehicles in configurable formations (road, grid, line). Handles vehicle selection from installed data with population-weighted randomization, paint assignment, and formation placement.
Public Functions
| Function | Signature | Description |
|---|---|---|
M.createGroup | (amount, params) → table | Creates a randomized vehicle group from installed vehicles |
M.spawnGroup | (group, amount, options) → groupId | Spawns a vehicle group in formation |
M.spawnProcessedGroup | (spawnData, spawnOptions) → groupId | Spawns pre-processed vehicle data with transforms |
M.fitGroup | (group, amount) → table | Resizes a group array to the target amount (loops or trims) |
M.placeGroup | (vehIds, options) | Teleports existing vehicles into a new formation |
M.teleportGroup | (vehIds, options) | Alias for placeGroup |
M.setVehicleSpawnData | (group, amount) → table | Parses vehicle group entries into spawn-ready data |
M.getInstalledVehicleData | (params) → table | Gets filtered vehicle/config data from installed models |
M.vehIdsToGroup | (vehIds) → table | Converts vehicle IDs to a group array |
M.spawnedVehsToGroup | (ignorePlayer) → table | Converts all spawned vehicles to a group array |
M.deleteVehicles | (amount, groupName) | Deletes vehicles spawned by this system |
M.setupVehicles | (amount, shuffle, mode, gap) → groupId | DEPRECATED - use spawnGroup |
M.onSpawnCCallback | (id) | Starts engines on spawned vehicles by default |
Module Settings
| Field | Default | Description |
|---|---|---|
M.startEngines | true | Spawn vehicles with engines running |
M.useFullData | false | Include population data in group entries |
Spawn Modes
| Mode | Description |
|---|---|
roadAhead | Ahead on road, facing away from start (default) |
roadBehind | Behind on road, facing towards start |
roadAheadAlt | Ahead on road, facing towards start |
roadBehindAlt | Behind on road, facing away from start |
traffic | Smart traffic lane placement |
raceGrid | Race starting grid (staggered 2-wide) |
raceGridAlt | Race grid, shifted diagonal |
lineLeft / lineRight | Line perpendicular to direction |
lineBehind / lineAhead | Line along direction |
lineAbove | Vertical stack |
Usage Example
-- Create a random group of 10 cars/trucks
local group = core_multiSpawn.createGroup(10, {
filters = {Type = {car = 1, truck = 0.5}},
country = "germany"
})
-- Spawn with road formation, 20m spacing
local groupId = core_multiSpawn.spawnGroup(group, 10, {
name = "myGroup",
mode = "roadAhead",
gap = 20,
shuffle = true,
randomPaints = true
})
-- Teleport existing vehicles into race grid
local vehIds = {101, 102, 103, 104}
core_multiSpawn.placeGroup(vehIds, {mode = "raceGrid", gap = 12})
-- Delete all spawned vehicles
core_multiSpawn.deleteVehicles()Filter Parameters
| Filter Key | Example | Description |
|---|---|---|
Type | {car = 1, truck = 0.4} | Vehicle type weights |
maxYear | 2005 | Maximum model year (0 = auto-current year) |
country | "germany" | Boost domestic vehicles |
Notes
- Population-weighted selection uses power-law distribution (
popPowerparameter). - Selected vehicles have their population reduced to avoid repetition.
- Spawning uses the job system for non-blocking operation (unless
options.instant). - Fires
onVehicleGroupSpawned(vehIds, groupId, name)on completion. - Queues additional groups if spawning is busy.
See Also
Multiseat Camera
Automatic camera system for multiseat mode. Calculates a shared camera view that encompasses all player vehicles by averaging positions and adjusting distance/FOV dynamically.
Online
Online services client. Manages authentication sessions, API calls to BeamNG servers, file downloads with progress tracking, and server-pushed instructions (messages, mod updates).