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
Drag Race DebugDrag Tree DisplayDrag Race APIDrag Racing ManagerDrag Strip Save SystemDrag Race TimingDrag Race Phases

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 Extensionsgameplaydrag

Drag Race Timing

Reference for `gameplay_drag_times`, which tracks all distance-based, velocity-based, and time-based measurements during a drag race.

Reference for gameplay_drag_times, which tracks all distance-based, velocity-based, and time-based measurements during a drag race.


Overview

Runs every frame to accumulate timer values for each racer. Uses distance interpolation between frames for sub-frame accuracy on distance triggers (reaction time, 60ft, 330ft, 1/8 mile, 1000ft, 1/4 mile). Also tracks trap speeds at 1/8 and 1/4 mile, 0-60 mph time, and braking G-force during emergency stop.


Exports

FunctionSignatureDescription
onExtensionLoaded()Fetches dragData, calls reset()
onUpdate(dtReal, dtSim, dtRaw)Main timer update loop
reset()Reset all timer values and frame histories
preStageStarted()Empty hook placeholder
dragRaceStarted(vehId)Enables timer tracking for a racer
resetDragRaceValues()Alias for reset()

Timer Types

TypeTriggerExample Timers
distanceTimerdistanceFromOrigin >= timer.distancereactionTime, time_60, time_330, time_1_8, time_1000, time_1_4
velocitydistanceFromOrigin >= timer.distancevelAt_1_8, velAt_1_4
timeToVelocityvehSpeed > timer.velocitytime_0_60 (0-60 mph)
brakingGDuring emergencyStop phase after 0.4sbrakingG
M.dragRaceStarted(vehId)-
M.onExtensionLoaded()-
M.onUpdate(dtReal, dtSim, dtRaw)-
M.preStageStarted()-
M.reset()-
M.resetDragRaceValues()-

How It Works

-- Timer activation flow:
-- 1. dragRaceStarted(vehId) sets racer.timersStarted = true
-- 2. Each frame, onUpdate increments timer.value by dtSim
-- 3. For each distance-based timer:
--    a. When distance crosses threshold, interpolate exact crossing time:
--       t = inverseLerp(prevDistance, currentDistance, threshold)
--       timer.value = timerValue - (1-t) * dtSim
--    b. For velocity timers, interpolate speed at crossing:
--       timer.value = lerp(prevSpeed, currentSpeed, t)
-- 4. When reactionTime is set, subtract it from the running timer
--    (so all subsequent times are relative to car movement, not tree)

Sub-Frame Accuracy

The system uses inverseLerp between previous and current distances to find the exact fraction of the frame where the distance threshold was crossed:

local t = inverseLerp(prevDistance, distanceFromOrigin, timer.distance)
timer.value = timerValue - (1 - t) * dtSim
-- t=0 means crossed at start of frame, t=1 at end

Braking G Measurement

During the emergencyStop phase:

  1. Wait 0.4 seconds for braking to stabilise
  2. Record start time, distance, and speed
  3. After deltaTime (1s) or vehicle stops, calculate deceleration

Frame History Debug

Timers listed in addFrameHistoryDebug (currently only reactionTime) store per-frame debug strings:

timer.frameHistory[n] = "Racer: 42 Frame 15: 0.15000s after start. Distance: 0.1234m ..."

Key Behaviors

  • All timers start at 0 and only accumulate when racer.timersStarted is true
  • Reaction time is subtracted from the running clock so subsequent times measure from car movement
  • Timer updates skip completed races (dragData.isCompleted)
  • The onExtensionLoaded hook initialises frameHistory for debug-tracked timers

See Also

  • drag/debug - Drag Race Debug Menu - Related reference
  • drag/display - Christmas Tree & Display Signs - Related reference
  • drag/dragBridge - Flowgraph / External API Bridge - Related reference
  • Gameplay Systems Guide - Guide

Drag Strip Save System

Reference for `gameplay_drag_saveSystem`, which handles loading drag strip data from JSON, converting legacy formats, managing dial times / race history, and spawning prefabs.

Drag Race Phases

Reference for `gameplay_drag_utils`, which provides all phase functions (`stage`, `countdown`, `race`, `stop`, `emergencyStop`), racer position tracking, tree light processing, win conditions, and bou

On this page

OverviewExportsTimer TypesHow It WorksSub-Frame AccuracyBraking G MeasurementFrame History DebugKey BehaviorsSee Also