RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Crash Test BoundariesCrash Test CountdownCrash Test ScoringCrash Test Task ListCrash Test Scenario Manager

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 ExtensionsgameplaycrashTest

Crash Test Scenario Manager

Reference for `gameplay_crashTest_scenarioManager`, the main orchestrator for crash test missions. Manages multi-step crash test scenarios including vehicle setup, AI control, crash detection, scoring

Reference for gameplay_crashTest_scenarioManager, the main orchestrator for crash test missions. Manages multi-step crash test scenarios including vehicle setup, AI control, crash detection, scoring, and step progression.


Overview

This is the central controller for crash test missions. It processes step data, manages vehicle freezing/unfreezing, handles crash detection events, orchestrates AI-controlled target vehicles, and transitions between steps with fade-to-black effects.


Dependencies

  • ui_apps_genericMissionData - Timer display
  • ui_apps_pointsBar - Score display
  • Loads secondary extensions at runtime: crashTestTaskList, crashTestScoring, crashTestBoundaries, crashTestCountdown, crashTestDamageChecker
  • Also manages freeroam_crashCamMode for crash camera replays

Exports

| Function | Signature | Description | |------ | M.dependencies | table | { 'ui_apps_genericMissionData', 'ui_apps_pointsBar' } |--- | M.trackVehiclesForCrash | () | nil | trackVehiclesForCrash | | M.clearMarkers | () | nil | clearMarkers | | M.setDebug | (_debug) | nil | setDebug |-|-----------| | M.onAnyMissionChanged | onAnyMissionChanged handler |-------------| | processData | (crashTestData, deactivateOther) | Initialize scenario from mission data | | startScenario | () | Begin the first step | | goToNextStepFromUI | () | Advance to next step (called from UI) | | startStepFromUI | () | Start the current step's countdown | | reset | () | Reset entire scenario to initial state | | activatesAllVehForReset | () | Re-activate all vehicles for reset | | getCrashTestData | () | Get current scenario state | | onUpdate | (dtReal, dtSim) | Per-frame update: markers, timers, AI checks | | onPreRender | (dt, dtSim) | Render target markers | | onVehicleCrashStarted | (crashStartData) | Handle crash start events | | onVehicleCrashEnded | (crashEndData) | Handle crash end events, evaluate success/failure | | onPlayerOutOfBounds | () | Fail step when player leaves boundary | | M.onExtensionUnloaded | onExtensionUnloaded handler | | M.onCrashCamEnded | onCrashCamEnded handler |


Step Processing

Each step in a crash test is sanitized from raw mission data into a structured format:

FieldDescription
plVehIdPlayer vehicle scene ID
jbeamTargetsList of target vehicle IDs
targetType"A single Jbeam", "Multiple Jbeams", or "Static object"
objective"Simple crash" or "Crash target vehicle into target area"
impactSpeedRequired impact speed in kph
aiType"ScriptAi" or "Stuck Throttle"
maxTimeTime limit for the step

How It Works

  1. processData() - Sanitizes raw step data, finds vehicles by dynamic field names, loads secondary extensions, freezes all player vehicles
  2. startScenario() - Initiates the first step transition with goToNextStep()
  3. goToNextStep() - Uses core_jobsystem to create a fade-to-black transition, then sets up the new step
  4. Countdown - A 3-second countdown via crashTestCountdown, after which the player is unfrozen and AI begins
  5. Crash Detection - Vehicles are tracked via gameplay_util_crashDetection. On crash start, the player is frozen; on crash end, success/failure is evaluated
  6. Step Completion - Scoring is calculated, the task list is updated, and the UI shows step results
-- Start a crash test scenario from mission data
gameplay_crashTest_scenarioManager.processData(missionStepsData, true)
gameplay_crashTest_scenarioManager.startScenario()

-- Get the scenario result after completion
local data = gameplay_crashTest_scenarioManager.getCrashTestData()
if data.scenarioFinished and data.accepted then
  -- Scenario passed
end

Failure Conditions

  • Player crashes outside the target area (static object targets)
  • Target vehicle damaged without player involvement
  • Non-target vehicle damaged
  • Target vehicle arrives without damage (AI script ends)
  • Time runs out
  • Player exits the boundary area

Key Behaviors

  • Vehicles from other steps can be deactivated (setActive(0)) during the current step
  • The crash camera mode is force-enabled during scenarios
  • Target markers update dynamically - hidden after crash starts
  • AI vehicles use either ScriptAi (path-following) or stuck throttle override
  • Step transitions use ui_fadeScreen for smooth fade-to-black effects
FunctionSignatureReturnsDescription
M.setDebug(_debug)nilsetDebug
M.onAnyMissionChanged(status, mission)nilonAnyMissionChanged
M.onExtensionUnloaded(extension)nilonExtensionUnloaded
M.onCrashCamEnded()nilonCrashCamEnded
M.clearMarkers()nilclearMarkers
M.trackVehiclesForCrash()niltrackVehiclesForCrash

Module Variables

VariableTypeDescription
M.dependenciestable{ 'ui_apps_genericMissionData', 'ui_apps_pointsBar' }
M.activatesAllVehForReset()-
M.getCrashTestData()-
M.goToNextStepFromUI()-
M.onPlayerOutOfBounds()-
M.onPreRender(dt, dtSim)-
M.onUpdate(dtReal, dtSim)-
M.onVehicleCrashEnded(crashEndData)-
M.onVehicleCrashStarted(crashStartData)-
M.processData(crashTestData, deactivateVehiclesFromOtherSteps_)-
M.reset()-
M.startScenario()-
M.startStepFromUI()-

See Also

  • crashTestBoundaries - Crash Test Boundary Checking - Related reference
  • crashTestCountdown - Crash Test Countdown Timer - Related reference
  • crashTestScoring - Crash Test Score Calculation - Related reference
  • Gameplay Systems Guide - Guide

Crash Test Task List

Reference for `gameplay_crashTest_crashTestTaskList`, which manages the in-game task list UI for crash test missions, showing step objectives and their completion status.

Crawl Boundaries

Reference for `gameplay_crawl_boundary`, which manages spatial boundaries for rock crawling trails. Spawns animated flag markers along boundaries, checks crawler positions against boundary zones, and

On this page

OverviewDependenciesExportsStep ProcessingHow It WorksFailure ConditionsKey BehaviorsModule VariablesSee Also