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
Freeroam CruisingFreeroam Drift Spots

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 Extensionsgameplaydriftfreeroam

Freeroam Drift Spots

Reference for `gameplay_drift_freeroam_driftSpots`, which manages freeroam drift zones - detecting when the player drifts through a start line, running the challenge, tracking scores/highscores, and i

Reference for gameplay_drift_freeroam_driftSpots, which manages freeroam drift zones - detecting when the player drifts through a start line, running the challenge, tracking scores/highscores, and integrating with the POI/big-map system.


Dependencies

gameplay_drift_general, gameplay_drift_drift, gameplay_drift_scoring, gameplay_drift_saveLoad


Exports

| Function | Signature | Description | |------ | M.dependencies | table | { |----|-----------|-------------| | detectStart | (lineId) | Check if player entered a start line while drifting | | onUpdate | (dtReal, dtSim, dtRaw) | Main loop - check end conditions | | onVehicleResetted | (id) | Improper end on vehicle reset | | onGetRawPoiListForLevel | (levelId, elements) | Inject drift spot POIs and big-map markers | | onDriftCompletedScored | () | Check objective completion, new highscore | | onSerialize / onDeserialized | (data) | Handle hot-reload during challenge | | getIsInTheConcludingPhase | () → bool | Post-challenge animation phase | | getIsInFreeroamChallenge | () → bool | Currently in a drift spot challenge | | getDriftDebugInfo | () → table | Debug toggle state | | getGC | () → number | Profiler garbage |


Internals

SymbolPurpose
linesAll start/finish lines loaded from drift spot data
activeLineCurrently active line (during a challenge)
isInFreeroamChallengeChallenge active flag
isInTheConcludingPhasePost-finish animation phase
options.concludingPhaseDuration2.5 s - end screen display time
options.maxWrongWayDist5 m - wrong-way tolerance
options.maxDistToIntendedRoad30 m - off-path tolerance
options.stopTimeToAbort1 s - stopped vehicle abort time

How It Works

Challenge Start

-- A start line is a rectangle in the world
-- Player must be inside rectangle AND drifting AND moving in startDir
gameplay_drift_freeroam_driftSpots.detectStart("spotName_lineOne")
-- If conditions met:
-- 1. Set context to "inFreeroamChallenge"
-- 2. Load bounds and race path
-- 3. Show tasklist with highscore and objectives

Challenge End - Proper

-- Cross the corresponding finish line (e.g., lineOne → lineTwo)
-- 1. Wrap up remaining score
-- 2. Show completion message with score
-- 3. Save score to leaderboard
-- 4. Reset to "inFreeroam" context

Challenge End - Improper

ReasonTrigger
wrongWayDrove back up the course past max distance
outOfBoundsToo far from intended road (>30m)
stoppedVelocity < 2 m/s for > 1 second
vehResetPlayer reset vehicle

Score & Objectives

-- Scores are saved per spot with license plate and timestamp
addNewScore(spotName, score)
-- Keeps top 10 scores, sorted descending

-- Objectives are defined in spot info:
-- {id = "bronze", score = 500, rewards = {bmra = 10}}
-- Career rewards are granted on first completion

POI Integration

-- Each line becomes a POI with:
-- 1. driftLineMarker - invisible trigger at line position
-- 2. bigmapMarker (lineOne only) - icon, name, preview, highscore
--    Uses "mission_drift_triangle" icon
--    Shows quickTravelPosRotFunction for teleporting

Key Behaviors

  • Each drift spot has two lines (lineOne, lineTwo) - either can be start or finish depending on direction
  • Line crossing uses isPointInsideRectangle() with local-space OBB test + velocity dot product for direction
  • correspondingLineName maps lineOne ↔ lineTwo for finish detection
  • Marker objects (cones, etc.) are hidden on load via scenetree.findObject
  • Score saving uses gameplay_drift_saveLoad.saveDriftSpotsScoresForSpotById()
  • New highscore flash only triggers once per challenge (hasAlreadyShownNewRecord)

Module Variables

VariableTypeDescription
M.dependenciestable{
M.detectStart(lineId)-
M.getDriftDebugInfo()-
M.getGC()-
M.getIsInFreeroamChallenge()-
M.getIsInTheConcludingPhase()-
M.onDeserialized(data)-
M.onDriftCompletedScored()-
M.onGetRawPoiListForLevel(levelIdentifier, elements)-
M.onSerialize()-
M.onUpdate(dtReal, dtSim, dtRaw)-
M.onVehicleResetted(id)-

See Also

  • drift/freeroam/cruising - Freeroam Drift Cruising UI Toggle - Related reference
  • Gameplay Systems Guide - Guide

Freeroam Cruising

Reference for `gameplay_drift_freeroam_cruising`, which automatically shows/hides the drift angle UI when the player sustains a drift chain while in freeroam.

Donut Zone

Reference for the donut stunt zone class, loaded via `require("gameplay/drift/stuntZones/donut")`.

On this page

DependenciesExportsInternalsHow It WorksChallenge StartChallenge End - ProperChallenge End - ImproperScore & ObjectivesPOI IntegrationKey BehaviorsModule VariablesSee Also