API ReferenceGE ExtensionseditorvehicleEditorliveEditor
Vehicle Editor - Vehicle Spawner
Tool for spawning and despawning multiple vehicles at specified positions within the Vehicle Editor, with interactive location picking via raycast.
Tool for spawning and despawning multiple vehicles at specified positions within the Vehicle Editor, with interactive location picking via raycast.
Module Exports
| Export | Type | Description |
|---|---|---|
M.menuEntry | string | "Other/Vehicle Spawner" - menu label (nested) |
M.open | function | Opens the spawner window |
M.onUpdate | hook | Renders ImGui window and picking overlay |
M.onEditorInitialized | hook | Populates vehicle list (up to 20 cars/trucks) |
M.onSerialize | hook | Persists window state |
M.onDeserialized | hook | Restores window state |
Key Internals
| Variable | Type | Purpose |
|---|---|---|
windowOpen | BoolPtr | Window visibility |
vehsList | table | Available vehicle list (Car/Truck types, max 20) |
pickingLocation | boolean | Whether user is picking spawn location |
startPos | vec3/nil | Chosen spawn origin position |
startYaw | number | Spawn direction in degrees (default 90) |
startDir | quat | Spawn direction as quaternion |
vehsData | table | Spawned vehicle references and initial positions |
How It Works
- On editor init, collects up to 20 Car/Truck type vehicles from
core_vehicles.getVehicleList() - "Spawn Vehicle" button opens a secondary selector window with vehicle buttons
- "Pick Start Location" enables terrain raycasting with mouse scroll for rotation
- Vehicles spawn in a line spaced 10m apart along the spawn direction
- "Despawn All" deletes all spawned vehicles
Lua Code Example
-- Open vehicle spawner
extensions.editor_vehicleEditor_liveEditor_veVehicleSpawner.open()
-- Vehicle list is populated on editor init:
-- for k, vehItem in ipairs(core_vehicles.getVehicleList().vehicles) do
-- if vehItem.model.Type == 'Car' or vehItem.model.Type == 'Truck' then
-- table.insert(vehsList, vehItem)
-- end
-- end
-- Location picking uses terrain raycast:
-- hit = cameraMouseRayCast(false, im.flags(SOTTerrain))
-- Vehicles preview as red triangles during picking
-- Rotation is adjusted via mouse wheel during picking:
-- tempStartYaw = tempStartYaw + io.MouseWheel * 5
-- tempStartDir = quatFromAxisAngle(vec3(0,0,1), math.rad(tempStartYaw))
-- Spawn positions are spaced 10m apart:
-- local spawnPos = startPos + startDir * vec3(10 * (i - 1), 0, 0)
-- local veh = core_vehicles.spawnNewVehicle(vehData.model.key, {pos = spawnPos, rot = startDir})
-- veh:queueLuaCommand("input.event('parkingbrake', 0, 1)")
-- Quick-spawn from selector window uses camera position:
-- local spawnPos = core_camera.getPosition()
-- local spawnRot = getCameraQuat()
-- Despawn removes all tracked vehicles:
-- for _, vehData in ipairs(vehsData) do
-- vehData.veh:delete()
-- endSee Also
- Adjustable Tech Car Tuner - Related reference
- Aero Debug - Related reference
- Crash Tester - Related reference
- World Editor Guide - Guide
Vehicle Editor - TCS Debug
Real-time Traction Control System (TCS) debugging tool that plots per-wheel brake factors, slip values, throttle factors, and slip thresholds as scrolling multi-line graphs.
Vehicle Editor - Scene View
Creates and manages multiple auxiliary scene views (render views) attached to the vehicle, supporting orthographic projections (left/right/front/back/top/bottom) and free 3D camera mode.