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

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 Extensionsgameplayrally

Snap-to-Road

Provides snap-to-road functionality in the world editor's rally editor. Wraps a driveline (linked list of points) with spatial queries, point partitioning, filtering, camera path playback, and debug v

Provides snap-to-road functionality in the world editor's rally editor. Wraps a driveline (linked list of points) with spatial queries, point partitioning, filtering, camera path playback, and debug visualization.


Constructor

local Snaproad = require('/lua/ge/extensions/gameplay/rally/snaproad')
local sr = Snaproad(driveline)

Public API - Navigation

FunctionSignatureReturnsDescription
C:closestSnapPoint(source_pos, useAllPoints)pointFinds closest driveline point to a world position
C:closestSnapPos(source_pos)vec3Returns position of closest snap point
C:nextSnapPoint(srcPos)pointNext point forward from closest to srcPos
C:prevSnapPoint(srcPos)pointPrevious point backward from closest to srcPos
C:firstSnapPoint()pointFirst point in the driveline
C:pointsBackwards(fromPoint, steps, limitPoints)pointWalk N steps backward, respecting limit points
C:pointsForwards(fromPoint, steps, limitPoints)pointWalk N steps forward, respecting limit points
C:distanceBackwards(fromPoint, meters, limitPoints)pointWalk backward by distance in meters
C:distanceForwards(fromPoint, meters, limitPoints)pointWalk forward by distance in meters
C:normalAlignPoints(point)prev, current, nextGets alignment points for normal calculation
C:forwardNormalVec(point)vec3Forward normal vector at a point
M.init(driveline)nilinit
M.groupPointsByCornerCall(points)nilgroupPointsByCornerCall
M.prevSnapPos(srcPos)nilprevSnapPos
M.nextSnapPos(srcPos)nilnextSnapPos
M.setPartitionToFilter()nilsetPartitionToFilter
M.partitionAllEnabled()nilpartitionAllEnabled
M.toggleCornerCalls()niltoggleCornerCalls

Public API - Partitioning

FunctionSignatureReturnsDescription
C:setPartitionToPacenote(pn)nilPartitions points around a pacenote (CS→CE)
C:clearPartition()nilClears single-pacenote partition
C:partitionAllPacenotes(notebook)nilPartitions all points by all pacenotes
C:clearAll()nilClears all partitioning and filtering
C:measurePartition()nilMeasures geometry of current partition via geoPacenotes
C:updateHalfpoint(pn)nilRecalculates midpoint between CS and CE on snaproad

Public API - Filtering

FunctionSignatureReturnsDescription
C:setFilter(wp)nilConstrains navigation to valid range for a waypoint
C:clearFilter()nilRemoves navigation filter
C:setFilterToAllPartitions()nilSets filter to all inter-pacenote partitions
C:setFilterPartitionPoint(point)nilSets filter to the partition containing a point

Public API - Visualization & Camera

FunctionSignatureReturnsDescription
C:drawDebugSnaproad(clrOverride)nilDraws snaproad points (respects partition/filter state)
C:drawDebugRecceApp()nilDraws for recce app (with height adjustment)
C:drawDebugCameraPlaying()nilDraws CS/CE markers and focus points during camera playback
C:setGlobalOpacity(opacity)nilSets rendering opacity (0-1)
C:playCameraPath()nilPlays camera along partition with buffers
C:stopCameraPath()nilStops camera playback
C:pointsForCameraPath(bufferBefore, bufferAfter)tableGets points for camera path (default 40m before, 20m after)

How It Works

Point Structure

Each driveline point has: id, pos (vec3), prev/next (linked list), partition (reference), optional cachedPacenotes.

Partition States

The snaproad operates in three modes:

  1. Default - shows all points
  2. Single partition - highlights CS→CE focus area with before/after context
  3. All partitions - splits entire driveline by all pacenotes (used for Ctrl+click new pacenote creation)

Waypoint Filter Logic

When a waypoint is selected for movement:

  • CS selected: Can move backward to previous CE, forward to own CE
  • CE selected: Can move backward to own CS, forward to next CS

Corner Call Visualization

Groups points by steering angle into subgroups with gradient colors (red→yellow→green), labeling each group with the corner call string.

-- Snap a position to the road
local sr = Snaproad(driveline)
local point = sr:closestSnapPoint(worldPos)
local snappedPos = point.pos

-- Partition around a pacenote for editing
sr:setPartitionToPacenote(pacenote)
sr:drawDebugSnaproad()

See Also

  • Rally Audio Manager - Related reference
  • Rally Camera Path Player - Related reference
  • Rally Client - Related reference
  • Gameplay Systems Guide - Guide

Rally Settings Manager

Loads and provides access to mission-level rally settings (notebook filename, selected codriver). Wraps the `MissionSettings` class for convenience.

Traffic Exclusion Zones

Creates traffic exclusion zones around rally stage infrastructure (start positions, pathnodes) to prevent AI traffic from interfering with rally routes. Zones are applied to the navgraph via `map.setT

On this page

ConstructorPublic API - NavigationPublic API - PartitioningPublic API - FilteringPublic API - Visualization & CameraHow It WorksPoint StructurePartition StatesWaypoint Filter LogicCorner Call VisualizationSee Also