Crash Test Countdown
Reference for `gameplay_crashTest_crashTestCountdown`, a simple countdown timer that displays a visual countdown and plays audio cues before a crash test step begins.
Reference for gameplay_crashTest_crashTestCountdown, a simple countdown timer that displays a visual countdown and plays audio cues before a crash test step begins.
Overview
Provides a count-down-from-N timer with flash messages ("3", "2", "1", "Go!") and corresponding audio events. When the countdown reaches zero, a callback function is invoked to start the step.
Exports
| Function | Signature | Description |
|---|---|---|
onUpdate | (dtReal, dtSim) | Tick the countdown timer each frame |
startNewCountdown | (duration, callback) | Begin a new countdown of duration seconds |
M.onUpdate | (dtReal, dtSim) | - |
M.startNewCountdown | (duration, callback_) | - |
Internals
- timer - Current remaining time in seconds
- old - Tracks the previous floored second to detect transitions
- callback - Function called when the countdown hits zero
Display & Sound
Each time the countdown crosses a whole-second boundary:
- A
ScenarioFlashMessageGUI hook displays the current number (or "Go!" at zero) - Audio events play:
UI_Countdown1for each tick,UI_CountdownGoat zero
How It Works
startNewCountdown(3, myCallback)initializes the timer to 3 seconds- Each frame,
onUpdatedecrements the timer bydtSim - When the floored timer changes (e.g., 3→2), a flash message and sound play
- At zero,
"Go!"is displayed, the go-sound plays, and the callback fires
-- Start a 3-second countdown, then unfreeze the player
gameplay_crashTest_crashTestCountdown.startNewCountdown(3, function()
-- Player is unfrozen and step begins
core_vehicleBridge.executeAction(veh, 'setFreeze', false)
end)Key Behaviors
- The countdown only ticks when
timer > 0 - Uses
dtSim(simulation time), so it pauses when the game is paused - The callback is fired exactly once when the timer expires
- Flash messages use
ScenarioFlashMessagewith full-screen styling (0.95size)
See Also
- crashTestBoundaries - Crash Test Boundary Checking - Related reference
- crashTestScoring - Crash Test Score Calculation - Related reference
- crashTestTaskList - Crash Test UI Task List - Related reference
- Gameplay Systems Guide - Guide
Crash Test Boundaries
Reference for `gameplay_crashTest_crashTestBoundaries`, which manages spatial boundaries for crash test missions. Checks whether the player vehicle is inside designated zones and triggers out-of-bound
Crash Test Scoring
Reference for `gameplay_crashTest_crashTestScoring`, which calculates and aggregates scores for crash test mission steps based on time, speed, damage, and impact location accuracy.