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
Drift Zone BoundsDrift Race PathDrift UI DisplayDrift Detection EngineDrift SystemDrift Quick MessagesDrift Save/LoadDrift ScoreboardDrift Scoring SystemDrift AudioDrift StallingDrift StatisticsDrift Stunt Zones

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 Extensionsgameplaydrift

Drift System

Reference for `gameplay_drift_general`, which is the central manager for the drift subsystem. Controls extension loading/unloading, context switching, debug state, freeze/pause logic, and coordinates

Reference for gameplay_drift_general, which is the central manager for the drift subsystem. Controls extension loading/unloading, context switching, debug state, freeze/pause logic, and coordinates all drift sub-extensions.


Dependencies

gameplay_drift_drift, gameplay_drift_scoring, gameplay_drift_statistics, gameplay_drift_saveLoad, gameplay_util_groundContact


Exports

State Management

FunctionSignatureDescription
setContext(newContext)Switch context, triggers extension updates
getContext() → stringCurrent context
setChallengeMode(mode)Set challenge mode, update extensions
getChallengeMode() → stringCurrent challenge mode
setPaused(bool)Pause scoring/detection
getPaused() → boolPaused state
getFrozen() → boolFrozen state (out of bounds / wrong way)
setDebug(bool)Enable/disable ImGui debug windows
getGeneralDebug() → boolDebug enabled
getExtensionDebug(extName) → boolDebug enabled for specific extension
getIsThereAnyDriftUIAppDisplayed() → boolAny drift app visible

Lifecycle

FunctionSignatureDescription
onUpdate()Check frozen state, manage sound extension
onExtensionLoaded()Scan for drift extension files
onVehicleResetted(vid)Hook onDriftPlVehReset for player vehicle
onAnyMissionChanged(status, mission)Context switching on mission start/stop
reset()Reset all loaded extensions
clear()Reset + clear stunt zones
onSerialize / onDeserialized(data)Persist debug state
onDriftAppMounted / onDriftAppUnmounted()Track UI app mount state

Context System

ContextDescription
inFreeroamDefault; drift spots enabled, cruising enabled
inChallengeFormal drift mission; scoreboard, stunt zones
inFreeroamChallengeFreeroam drift spot challenge; bounds, destination
inAnotherMissionTypeNon-drift mission active; drift detection disabled

Variable Extension Loading

Extensions are loaded/unloaded based on context and challenge mode:

variableExtensions = {
  gameplay_drift_display     = {contexts = {"inChallenge", "inFreeroamChallenge", "inFreeroam"}},
  gameplay_drift_bounds      = {contexts = {"inChallenge", "inFreeroamChallenge"}},
  gameplay_drift_destination = {challengeModes = {"A to B", ...}, contexts = {"inFreeroamChallenge"}},
  gameplay_drift_stuntZones  = {contexts = {"inChallenge"}},
  gameplay_drift_quickMessages = {contexts = {"inFreeroam", "inChallenge", "inFreeroamChallenge"}},
  gameplay_drift_scoreboard  = {contexts = {"inChallenge"}},
  gameplay_drift_freeroam_driftSpots = {contexts = {"inFreeroam", "inFreeroamChallenge"}},
  gameplay_drift_freeroam_cruising   = {contexts = {"inFreeroam"}},
  gameplay_drift_stallingSystem      = {challengeModes = {"Gymkhana"}},
  gameplay_drift_sounds      = {manualLoad = true},  -- loaded by sound check
}

Freeze Logic

-- Checked every frame via checkFrozen():
frozen = outOfBounds or goingWrongWay or isInConcludingPhase
-- When frozen: scoring stops, drift detection data not cleared
-- Frozen state is consumed by scoring and display systems

Sound Extension Management

-- Sound loads when drift UI app is displayed
-- Sound unloads when drift UI app is hidden
-- Prevents audio resources being held when not drifting

Challenge Modes

ModeDescription
NoneDefault (freeroam)
A to BStart-to-finish with destination tracking
A to B with stunt zonesA-to-B plus stunt zone bonuses
GymkhanaEnclosed area with stalling system
Competition(Reserved)

Key Behaviors

  • First onUpdate call runs init() which sets context to "inFreeroam" and resets
  • When a non-drift mission starts, context switches to "inAnotherMissionType" and crash detection is removed
  • Context changes fire extensions.hook("onDriftContextChanged", context, oldContext)
  • All loaded drift extensions are tracked in loadedExtensions table with debug info
  • checkLoadedExtensions() scans all .lua files under gameplay/drift/ to build the extension registry

Public API

FunctionSignatureReturnsDescription
M.getDriftDebugInfo()nilgetDriftDebugInfo

Module Variables

VariableTypeDescription
M.dependenciestable{"gameplay_drift_drift", "gameplay_drift_scoring", "gameplay_drift_statistics",
M.clear()-
M.getChallengeMode()-
M.getContext()-
M.getExtensionDebug(extName)-
M.getFrozen()-
M.getGeneralDebug()-
M.getIsThereAnyDriftUIAppDisplayed()-
M.getPaused()-
M.onAnyMissionChanged(status, mission)-
M.onDeserialized(data)-
M.onDriftAppMounted()-
M.onDriftAppUnmounted()-
M.onExtensionLoaded()-
M.onSerialize()-
M.onUpdate()-
M.onVehicleResetted(vid)-
M.reset()-
M.setChallengeMode(newChallengeMode)-
M.setContext(newContext)-
M.setDebug(value)-
M.setPaused(newPaused)-

See Also

  • drift/bounds - Drift Zone Boundary Detection - Related reference
  • drift/destination - Race Path & Wrong-Way Detection - Related reference
  • drift/display - Drift UI & HUD Management - Related reference
  • Gameplay Systems Guide - Guide

Drift Detection Engine

Reference for `gameplay_drift_drift`, which is the central drift detection engine. Determines when the vehicle is drifting, tracks angle/speed/distance, detects crashes and spinouts, and provides all

Drift Quick Messages

Reference for `gameplay_drift_quickMessages`, which detects special drift achievements (close calls, big angles, long drifts, etc.) and awards bonus points with on-screen messages.

On this page

DependenciesExportsState ManagementLifecycleContext SystemVariable Extension LoadingFreeze LogicSound Extension ManagementChallenge ModesKey BehaviorsPublic APIModule VariablesSee Also