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
| Function | Signature | Returns | Description |
|---|---|---|---|
M.drawDebugPlane | (pos, rot, normals?) | nil | Draws a purple translucent plane with optional axis normals |
M.drawVehicleToPlaneDebug | (vehPos, planePos, rot, ...) | nil | Draws vehicle-to-plane distance with signed distance visualization |
M.drawDebugVehiclePoint | (vehPos, inside) | nil | Draws green (inside) or red (outside) sphere at vehicle position |
M.freezeVehicle | (vehId, logTag) | boolean | Freezes vehicle in place via setFreeze action |
M.unfreezeVehicle | (vehId, logTag) | boolean | Unfreezes vehicle |
M.drawMiddleInfo | (im, nodeData, formatTimeFromSeconds) | nil | Renders ImGui debug info panel for countdown state |
M.drawMiddleProgress | (im, state, duration, timer, STATE_RUNNING, STATE_FINISHED) | nil | Renders 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:
- Plane detection: Countdown nodes define a start line as a plane; these functions visualize the plane and compute whether the vehicle has crossed it
- Vehicle staging:
freezeVehicleholds the car at the line during countdown;unfreezeVehiclereleases on "GO" - 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