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
Gameplay Race RouteGameplay Route

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 Extensionsgameplayroute

Gameplay Race Route

Extended version of `route.lua` designed for racing. Adds metadata support, callbacks for route events, original position tracking for re-routing, and merge-priority handling for close waypoints.

Extended version of route.lua designed for racing. Adds metadata support, callbacks for route events, original position tracking for re-routing, and merge-priority handling for close waypoints.


Constructor

local RaceRoute = require('gameplay/route/raceRoute')
local route = RaceRoute(removeFirst, useMapPathfinding, closeDistSquared, logTag)
ParameterTypeDefaultDescription
removeFirstbool?trueRemove first node when on-path
useMapPathfindingbool?trueUse map A* pathfinding
closeDistSquarednumber?1Squared distance for node merging

Methods

MethodSignatureReturnsDescription
setRouteParams(cutOff, dirMult, penAbove, penBelow, wD, wZ)nilSet pathfinding weights
setupPath(fromPos, toPos)nilCreate route between two positions
setupPathMulti(positions)nilCreate route through multiple vec3 positions
setupPathMultiWithMetadata(positions)nilCreate route with metadata per position
setupPathMultiWaypoints(wpList)nilCreate route using map waypoint names
calcDistance()numberRecalculate distToTarget for all nodes
stepAhead(stepDist, reset)table?Get position at distance along route
getPositionOffset(currentPos)idx, minDistFind closest segment index
shortenPath(idx)nilRemove passed nodes from front
trackVehicle(veh)idx, minDistUpdate route for vehicle position
trackPosition(pos)idx, minDistUpdate route for arbitrary position
recalculateRoute(startPos)nilRecalculate from position using remaining fixed points
recalculateRouteWithOriginalPositions(startPos)nilRecalculate using original fixed positions
clear()nilClear all path data

Callbacks

route.callbacks = {
  onPointProcessed = function(point) end,        -- called for each point after setup
  shouldPointBeFixedForRecalc = function(wp) end, -- filter points during recalc
  onRouteShortened = function(removed) end,        -- when nodes are removed
  onMetadataMerge = function(i, last, cur) end,    -- custom merge logic for close nodes
}

How It Works

  1. setupPathMultiWithMetadata builds a route through fixed positions using map.getPointToPointPath
  2. Intermediate map nodes are inserted between fixed waypoints
  3. Start/end of each segment are adjusted via fixStartEnd for smooth transitions
  4. Nodes closer than closeDistSquared are merged (metadata merge via callback)
  5. updatePathForPos tracks movement - shortens path and recalculates when off-route
  6. originalFixedPositions preserves the initial waypoints for full re-routing
local route = RaceRoute(true, true, 1)
route:setRouteParams(0.5, 1e3)

-- Setup with metadata
route:setupPathMultiWithMetadata({
  { pos = vec3(0, 0, 0) },
  { pos = vec3(100, 0, 0), metadata = { stableId = "wp1" } },
  { pos = vec3(200, 50, 0), metadata = { stableId = "wp2" } },
})

-- Track vehicle
local idx, dist = route:trackVehicle(be:getPlayerVehicle(0))
if route.done then print("Route complete!") end

Dependencies

  • map - getPointToPointPath, getMap, getNodeLinkCount
  • extensions.hook('onRecalculatedRoute') - fires on recalculation
FunctionSignatureReturnsDescription
M.getNextFixedWP()nilgetNextFixedWP
M.trackCamera()niltrackCamera

See Also

  • Gameplay Route - Related reference
  • Gameplay Systems Guide - Guide

Rally Utility Normalizer

Simple text normalization module that applies word-replacement mappings to pacenote strings.

Gameplay Route

Core route class for navigation pathfinding. Creates a path between positions using the map graph, tracks vehicle position along it, and auto-recalculates when off-route.

On this page

ConstructorMethodsCallbacksHow It WorksDependenciesSee Also