API ReferenceGE Extensionsgameplayrace
Race Start Position
Object class representing a spawn/recovery position in a race path. Stores position and rotation, and provides methods to calculate vehicle placement transforms and teleport vehicles.
Object class representing a spawn/recovery position in a race path. Stores position and rotation, and provides methods to calculate vehicle placement transforms and teleport vehicles.
Constructor
local StartPosition = require('/lua/ge/extensions/gameplay/race/startPosition')
local sp = StartPosition(race, name)Public API
| Method | Signature | Returns | Description |
|---|---|---|---|
init | (race, name) | nil | Initializes with position and rotation |
set | (pos, rot) | nil | Sets position and rotation |
calculateVehiclePosRot | (vehId, lowPrecision) | newPos, vehRot | Calculates vehicle-specific transform using OOBB offsets |
moveResetVehicleTo | (vehId, lowPrecision, repair) | newPos, vehRot | Teleports a vehicle to this start position |
setToVehicle | (vehId) | nil | Sets this start position from a vehicle's current transform |
getFrontCorners | (width, length) | table | Returns front corner positions for detection |
setRoutePoint / getRoutePoint | (rp) | rp | Dynamic route point reference |
setStaticRoutePoint / getStaticRoutePoint | (rp) | rp | Static route point reference |
onSerialize / onDeserialized | Serialization support | ||
drawDebug | (drawMode, clr) | nil | Draws position as colored triangles |
Internals
| Field | Type | Description |
|---|---|---|
race | Path | Parent path reference |
id | number | Unique ID |
name | string | Display name (e.g., "standing", "rolling") |
pos | vec3 | World position |
rot | quat | World rotation |
routePoint | table/nil | Associated dynamic route point |
staticRoutePoint | table/nil | Associated static route point |
How It Works
calculateVehiclePosRot()uses the vehicle's OOBB (oriented bounding box) to compute a precise spawn transform:- Extracts the front-left, front-right, back-left corner positions from the OOBB
- Computes a local offset from the vehicle's position to the front-left corner
- Maps this offset into the start position's coordinate frame
lowPrecisionmode places the vehicle 2m behind and 0.5m above (for first-frame spawn when OOBB isn't ready)
moveResetVehicleTo()callscalculateVehiclePosRot()and either directly sets position/rotation (with repair) or usesspawn.safeTeleport(without repair)setToVehicle()captures a vehicle's current position/rotation, using terrain height for the center point
Usage Examples
-- Create a start position at a specific location
local sp = StartPosition(path, "Default Start")
sp:set(vec3(100, 200, 50), quatFromDir(vec3(0, 1, 0), vec3(0, 0, 1)))
-- Teleport player vehicle to this start
sp:moveResetVehicleTo(playerId)
-- Capture current vehicle position as a start position
sp:setToVehicle(playerId)Notes
- Used for: default starts, reverse starts, rolling starts, and recovery points at pathnodes
- The path references start positions by ID fields:
defaultStartPosition,reverseStartPosition,rollingStartPosition,rollingReverseStartPosition - Debug drawing renders a colored arrow-like shape showing position and orientation
repairparameter defaults totrue; whenfalse, uses safe teleport without resetting vehicle damage
See Also
- Race Pacenote - Related reference
- Race Path - Related reference
- Race Pathnode - Related reference
- Gameplay Systems Guide - Guide
Race Segment
Object class representing a segment (connection) between two pathnodes in a race path. Supports three containment modes: waypoint, capsules, and navpath.
Rally Audio Manager
Manages a queue of pacenote audio playback and pauses for the rally co-driver system. Handles sequential playback with breath timing between notes and damage interruption.