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
Rally Audio ManagerRally Camera Path PlayerRally ClientRally Cut CaptureRally EnumsRally Extension HelperRally GeometryRally ManagerRecce ManagerRecce AppRecce SettingsRally Settings ManagerSnap-to-RoadTraffic Exclusion ZonesRally UtilityRally Vehicle CaptureRally Vehicle Tracker
Rally Driveline MeasurementRally Driveline RouteRally Driveline V3Rally Driveline Point ListRally Driveline Utility

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 Extensionsgameplayrallydriveline

Rally Driveline Route

The core driveline routing system for rally stages. Merges race pathnodes and pacenote waypoints into a navigable route, tracks the vehicle's position along it, and triggers pacenote audio events base

The core driveline routing system for rally stages. Merges race pathnodes and pacenote waypoints into a navigable route, tracks the vehicle's position along it, and triggers pacenote audio events based on distance and speed.


Constructor

local DrivelineRoute = require('/lua/ge/extensions/gameplay/rally/driveline/drivelineRoute')
local dr = DrivelineRoute()

Public API

MethodSignatureReturnsDescription
init()nilInitializes with default state and callback slots
isLoaded()boolWhether the route has been successfully loaded
loadRouteFromRecordedDriveline(racePath, notebookPath, pointsList)boolLoads and builds route from recorded driveline points
recalculate()boolRecalculates the dynamic route from current vehicle position
setRecalcNeeded()nilFlags that a recalculation is needed (e.g., after vehicle reset)
setVehicleTracker(vehicleTracker)nilSets the vehicle position/speed tracker
getPacenotes()tableReturns sorted pacenote list
getNextPacenote()pacenoteReturns the next pacenote to evaluate
getNearestRoutePoint(pos)vec3/nilFinds the closest point on the static route
onUpdate(dtReal, dtSim, dtRaw)nilPer-frame update: tracks position, evaluates pacenote triggers
setTrackMouseLikeVehicle(val)nilEnables mouse-based positioning for debugging

Callback Slots

CallbackParametersDescription
onPacenoteCsDynamicHit(pacenote, shouldTriggerAudio)Dynamic timing trigger (speed-based)
onPacenoteCsImmediateHit(pacenote, shouldTriggerAudio)Immediate trigger (first pacenote)
onPacenoteCsStaticHit(pacenote, shouldTriggerAudio)At corner start position
onPacenoteCeStaticHit(pacenote, shouldTriggerAudio)At corner end position
onPacenoteCsOffsetHit(pacenote, shouldTriggerAudio, offset)At meter offset from CS
onPacenoteCeOffsetHit(pacenote, shouldTriggerAudio, offset)At meter offset from CE
onPacenoteCornerPercentHit(pacenote, shouldTriggerAudio, percent)At percentage between CS and CE

Internals

Route Loading Pipeline (loadRouteFromRecordedDriveline)

  1. Race setup: autoConfig() on the race path
  2. Pre-route points: Driveline recording points become the base route
  3. KD-tree build: 3D KD-tree for fast closest-segment lookups
  4. Insert start/stop positions: Start position and stop zone markers
  5. Insert race pathnodes: Checkpoints and split points
  6. Re-index KD-tree: Rebuild after race pathnode insertions
  7. Insert pacenote waypoints: Corner start (CS) and corner end (CE) waypoints
  8. Trim route: Remove points before start and after stop zone
  9. Build dynamic route: raceRoute with metadata merge callbacks
  10. Build static route: Non-recalculating copy for distance lookups
  11. Build static KD-tree: For fast nearest-point queries
  12. Calculate splits: Distance data for each race pathnode
  13. Cache pacenote lengths: Distance between CS and CE for each pacenote

Dynamic Audio Triggering

The evaluatePacenoteEvents method calculates when to trigger audio:

  • Dynamic trigger: timeToCS < (baseCodriverTiming + scaledAudioLen) × speedMultiplier
    • Speed multiplier scales from 1.0 (at 50 mph) to 1.5 (at 90 mph)
    • Audio length is scaled by 0.75 factor
  • Static triggers: Fire when vehicle distance to the point < 0.1m threshold
  • Events tracked per pacenote: csDynamicHit, csImmediateHit, csStaticHit, ceStaticHit, meter offsets, corner percentages

Key Parameters

ParameterDefaultDescription
defaultCodriverTiming3.0sFallback timing if setting unavailable
audioLenScaler0.75Scales audio length for threshold calculation
scaleMinSpeedMph50Speed where multiplier begins
scaleMaxSpeedMph90Speed where multiplier maxes out
minMultiplier1.0Minimum speed multiplier
maxMultiplier1.5Maximum speed multiplier
minEvalSpeedMph1.0Minimum speed to evaluate pacenotes
minWaitTimeSinceRecalc2.0sCooldown after recalculation

How It Works

  1. Route is built by inserting race pathnodes and pacenote waypoints into a driveline point list using KD-tree nearest-segment lookup
  2. Two routes are maintained: a dynamic route that shortens as the vehicle progresses, and a static route for fixed distance lookups
  3. On each frame, the vehicle position is tracked along the dynamic route
  4. Pacenotes are evaluated in a sliding window (current + 5 lookbehind)
  5. Audio triggering uses time-to-corner-start based on current speed, with speed-dependent scaling
  6. On vehicle reset, setRecalcNeeded() triggers full route recalculation with event state recovery

Notes

  • Uses kdtreepoint3d for 3D nearest-point queries and raceRoute for route tracking
  • Point insertion uses closest line segment detection with a search window of 4
  • Metadata merge callbacks prevent losing race pathnode or pacenote data when route points are combined
  • The shouldPointBeFixedForRecalc callback ensures important route points survive recalculation
  • Split data provides distance labels (km) for UI display
FunctionSignatureReturnsDescription
M.enableTriggerLogging()nilenableTriggerLogging
M.getPacenoteEvent(pacenote)nilgetPacenoteEvent
M.callPacenoteEventCallback(callbackFn, ...)nilcallPacenoteEventCallback
M.getSpeed()nilgetSpeed
M.getPosition()nilgetPosition
M.evaluatePacenotesWindow(speedMs)nilevaluatePacenotesWindow
M.enableTrackMouseLikeVehicleMovement(val)nilenableTrackMouseLikeVehicleMovement
M.updateMouseLikeVehicle(dtSim)nilupdateMouseLikeVehicle
M.getFinishLineDistOffset()nilgetFinishLineDistOffset
M.getDistanceMeters()nilgetDistanceMeters
M.getDistanceKmString()nilgetDistanceKmString
M.getRaceCompletionData()nilgetRaceCompletionData
M.getPointDistanceFromStartMeters(point)nilgetPointDistanceFromStartMeters
M.getPointDistanceFromStartKm(point)nilgetPointDistanceFromStartKm
M.drawDebugDrivelineRoute(drawRoute, drawPacenotes, drawLimit, monochrome, static, drawHiddenPathnodes, drawRoutePathnodes, drawPointI, drawPointMetadata, drawPacenoteText)nildrawDebugDrivelineRoute
M.drawDebugDrivelineRouteShort(dist)nildrawDebugDrivelineRouteShort
M.buildElevationProfile()nilbuildElevationProfile

See Also

  • Rally Driveline Measurement - Related reference
  • Rally Driveline V3 - Related reference
  • Rally Driveline Point List - Related reference
  • Gameplay Systems Guide - Guide

Rally Driveline Measurement

Stub class for driveline measurement functionality. Currently a placeholder with only an `init` method.

Rally Driveline V3

Third-generation driveline system for rally stages. Loads recorded driveline data from recce sessions, simplifies it using RDP algorithm, generates smooth Catmull-Rom splines, and produces final drive

On this page

ConstructorPublic APICallback SlotsInternalsRoute Loading Pipeline (loadRouteFromRecordedDriveline)Dynamic Audio TriggeringKey ParametersHow It WorksNotesSee Also