RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Bus DriverDamage GoalDemolition DerbyDistance GoalDrift GoalFinish Race GoalNo-Move GoalPosition GoalQuick RaceQuick Race LoaderRace MarkersRace DebugRace Goals ManagerRace UIScenario HelperScenario EngineScenarios LoaderSpeed GoalTime Limit GoalWaypoint ActionScenario Waypoints

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 Extensionsscenario

Drift Goal

A scenario goal that calculates drift scores from vehicle angle and speed, supports combo chains, and triggers win/fail based on minimum drift score thresholds.

A scenario goal that calculates drift scores from vehicle angle and speed, supports combo chains, and triggers win/fail based on minimum drift score thresholds.


Internal State

FieldTypeDescription
M.instancesvariesAssigned as {}

Public API

FunctionSignatureDescription
M.init(scenario)Parses drift goals, initializes scoring state
M.processState(scenario, state, stateData)Calculates drift score each tick, handles session end
M.updateFinalStatus(scenario, instance)Reports final drift score to statistics system

Goal JSON Schema

{
  "goal": {
    "drift": {
      "minDrift": 500,
      "maxDrift": 10000,
      "timeAllowance": 60,
      "msg": "scenarios.drift.customWin",
      "failMsg": "scenarios.drift.customFail"
    }
  }
}
FieldTypeDescription
minDriftnumberMinimum score to pass
maxDriftnumberMaximum reportable score (clamped)
timeAllowancenumberOptional time limit in seconds
msglocalizedStringWin message
failMsglocalizedStringFail message

Scoring Algorithm

angleBonus = distance(directionVector, normalizedVelocity) × 10
speedBonus = velocity.length × 0.15
driftBonus = floor(angleBonus × speedBonus)

Filters

  • angleBonus clamped to 2–10 (excludes spinouts > 10, shallow drifts < 2)
  • speedBonus must be > 1 (excludes very low speed)
  • Combo multiplier: Chaining drifts within a cooldown grace period increases (combo + 1)×

Drift Descriptions

Score RangeDescription
√(pts/30) = 1"Tiny Drift"
2"Small Drift"
3"Nice Drift"
4"Great Drift!"
5"Awesome Drift!"
6"Spectacular Drift!"
7"Incredible Drift!"
8+"Absurd Drift!"

How It Works

  1. Each tick, computes angle between direction and velocity vectors
  2. Multiplies by speed to get instantaneous drift points
  3. Accumulates into total driftScore with combo multiplier
  4. Grace period (1s cooldown) allows chaining drifts into combos
  5. On race result or time expiry, calls sessionEnd to finish scenario
  6. Score is compared against minDrift to determine pass/fail

Usage Examples

-- Scenario JSON: score at least 1000 drift points
{
  "vehicles": {
    "scenario_player0": {
      "goal": {
        "drift": {
          "minDrift": 1000,
          "maxDrift": 50000,
          "timeAllowance": 120
        }
      }
    }
  }
}

Key Notes

  • Uses map.objects for vehicle velocity and direction data
  • Cooldown between drifts is 1 second (decrements by 0.25/tick)
  • Messages displayed via helper.realTimeUiDisplay
  • Score clamped to maxDrift on session end
  • Re-tracks vehicle if map object data is missing

See Also

  • Scenario Bus Driver - Bus Route Scenario Logic - Related reference
  • Scenario Damage Goal - Damage-Based Win/Fail Condition - Related reference
  • Scenario Demolition Derby - Last Vehicle Moving Wins - Related reference
  • Scenario System Guide - Guide

Distance Goal

A scenario goal that monitors the distance between two vehicles and triggers win or fail when distance thresholds are exceeded.

Finish Race Goal

A scenario goal that tracks whether a vehicle finishes a race. Supports both "must finish" and "must win" modes.

On this page

Internal StatePublic APIGoal JSON SchemaScoring AlgorithmFiltersDrift DescriptionsHow It WorksUsage ExamplesKey NotesSee Also