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 Loop PenaltiesRally AttemptsRally Event LogRally Loop ManagerRoad Section Penalty KeeperRally Schedule UtilitiesSpeeding DetectorStaged Countdown TestStaged Countdown Utilities

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 Extensionsgameplayrallyloop

Staged Countdown Utilities

Shared utility functions for the staged countdown system. Provides debug drawing helpers (plane visualization, vehicle-to-plane distance, vehicle point), vehicle freeze/unfreeze controls, and ImGui de

Shared utility functions for the staged countdown system. Provides debug drawing helpers (plane visualization, vehicle-to-plane distance, vehicle point), vehicle freeze/unfreeze controls, and ImGui debug UI rendering for countdown state.


Public API

FunctionSignatureReturnsDescription
M.drawDebugPlane(pos, rot, normals?)nilDraws a purple translucent plane with optional axis normals
M.drawVehicleToPlaneDebug(vehPos, planePos, rot, ...)nilDraws vehicle-to-plane distance with signed distance visualization
M.drawDebugVehiclePoint(vehPos, inside)nilDraws green (inside) or red (outside) sphere at vehicle position
M.freezeVehicle(vehId, logTag)booleanFreezes vehicle in place via setFreeze action
M.unfreezeVehicle(vehId, logTag)booleanUnfreezes vehicle
M.drawMiddleInfo(im, nodeData, formatTimeFromSeconds)nilRenders ImGui debug info panel for countdown state
M.drawMiddleProgress(im, state, duration, timer, STATE_RUNNING, STATE_FINISHED)nilRenders ImGui progress bar for countdown

Internals

Debug Plane Drawing

drawDebugPlane renders a purple translucent quad at pos with orientation rot. When normals is true, also draws:

  • Green arrow → "back" (plane normal, +Y axis)
  • Red arrow → "front" (-Y axis)

Vehicle-to-Plane Distance

drawVehicleToPlaneDebug calculates signed distance from vehicle to a plane:

  • Uses dot product of vehicle-to-plane vector with plane normal
  • Sign is flipped so negative = past line, positive = before line
  • Draws: closest point on plane (colored sphere), line from vehicle to plane, distance text at midpoint
  • Orange = past the line, Green = before the line

Vehicle Freeze

Uses core_vehicleBridge.executeAction(veh, 'setFreeze', true/false) to lock/unlock vehicle physics. Used during staged countdown to hold the vehicle at the start line.

ImGui Debug Panels

drawMiddleInfo displays:

  • Test mode indicator (yellow)
  • Wall clock time
  • Epoch and scheduled event time
  • Time until event and staging check
  • Current state and reschedule count
  • Vehicle zone/staged status

drawMiddleProgress shows a progress bar based on countdown state (waiting / running / done).


How It Works

These utilities support the staged countdown flowgraph nodes:

  1. Plane detection: Countdown nodes define a start line as a plane; these functions visualize the plane and compute whether the vehicle has crossed it
  2. Vehicle staging: freezeVehicle holds the car at the line during countdown; unfreezeVehicle releases on "GO"
  3. Debug UI: ImGui panels provide real-time visibility into countdown timing and state

Usage Example

local utils = require('gameplay/rally/loop/stagedCountdownUtils')

-- Draw start line plane
utils.drawDebugPlane(startLinePos, startLineRot, true)

-- Check vehicle distance to start line
utils.drawVehicleToPlaneDebug(vehPos, planePos, rot, normal, toVeh, closest, mid)

-- Freeze vehicle for staged start
utils.freezeVehicle(vehicleId, 'stagedCountdown')

-- Render debug info
utils.drawMiddleInfo(im, nodeData, formatFn)

See Also

  • Rally Loop Penalties - Related reference
  • Rally Attempts - Related reference
  • Rally Event Log - Related reference
  • Gameplay Systems Guide - Guide

Staged Countdown Test

Class-based test mode implementation for the staged countdown system. Simulates rally epoch timing and scheduled event scheduling without requiring a full rally loop manager. Used for testing countdow

Rally Codriver

Class representing a rally co-driver within a notebook. Each codriver has a name, language, voice setting, and unique persistent key (pk). Codrivers determine which language and voice are used for pac

On this page

Public APIInternalsDebug Plane DrawingVehicle-to-Plane DistanceVehicle FreezeImGui Debug PanelsHow It WorksUsage ExampleSee Also