Drift Stunt Zones
Reference for `gameplay_drift_stuntZones`, which manages the lifecycle, detection, rendering, and scoring of drift stunt zones (donuts, drift-throughs, hit poles, near poles).
Reference for gameplay_drift_stuntZones, which manages the lifecycle, detection, rendering, and scoring of drift stunt zones (donuts, drift-throughs, hit poles, near poles).
Dependencies
gameplay_drift_general
Overview
Central manager for all stunt zone objects. Handles spawning zones from data, per-frame detection of player interactions, cooldown management, decal rendering, and forwarding accomplishments to the scoring/stalling systems.
Exports
| Function | Signature | Description |
|---|---|---|
onUpdate | (dtReal, dtSim, dtRaw) | Per-frame: detection, cooldowns, debug UI |
onExtensionUnloaded | () | Clears all stunt zones |
onDriftStatusChanged | (isDrifting) | Resets donut angle tracking when drift ends |
onDriftDebugChanged | () | Resets draw lines toggle |
onVehicleDestroyed | (vehId) | Forwards to each stunt zone's onVehicleDestroyed |
onSerialize | () | Clears all zones on serialize |
onAnyStuntZoneAccomplished | (data) | Forwards to stalling system and fires data.subHookName hook |
clear | () | Removes and cleans up all stunt zones |
reset | () | Resets all stunt zones to initial state |
setStuntZones | (zones) | Creates stunt zones from data array (clears existing first) |
getStuntZones | () | Returns the stunt zones table |
increaseDecalPool | (max) | Expands the decal pool to max entries |
getDecalColor | (cooldownPerc, filledPerc, t) | Returns color based on cooldown/fill state |
getLineThickness | (linePos) | Returns thickness based on distance to camera |
getGreenColor | () | Returns green ColorF |
getWhiteColor | () | Returns white ColorF |
getRedColor | () | Returns red ColorF |
getDriftDebugInfo | () | Returns {default=true, canBeChanged=true} |
getDrawLines | () | Returns whether debug lines should be drawn |
clearStuntZone | (id) | Removes a specific stunt zone by id |
M.clear | () | - |
M.clearStuntZone | (id) | - |
M.dependencies | value | - |
M.getDecalColor | (cooldownPerc, filledPerc, t) | - |
M.getDrawLines | () | - |
M.getDriftDebugInfo | () | - |
M.getGreenColor | () | - |
M.getLineThickness | (linePos) | - |
M.getRedColor | () | - |
M.getStuntZones | () | - |
M.getWhiteColor | () | - |
M.increaseDecalPool | (max) | - |
M.onAnyStuntZoneAccomplished | (data) | - |
M.onDriftDebugChanged | () | - |
M.onDriftStatusChanged | (isDrifting) | - |
M.onExtensionUnloaded | () | - |
M.onSerialize | () | - |
M.onUpdate | (dtReal, dtSim, dtRaw) | - |
M.onVehicleDestroyed | (vehId) | - |
M.reset | () | - |
M.setStuntZones | (zones) | - |
Zone Data Format (input to setStuntZones)
{
type = "donut"|"driftThrough"|"hitPole"|"nearPole",
pos = vec3(...),
cooldown = number, -- seconds (donut/driftThrough)
scl = number|vec3(...), -- radius (donut) or dimensions (driftThrough)
rot = quat(...), -- orientation (driftThrough only)
score = number, -- optional, defaults from scoring options
}Key Behaviors
- Each zone type is loaded via
require("gameplay/drift/stuntZones/"..type)as a class factory - Near-zone detection triggers
onNearStuntZoneFirsthook once per zone type for help messages - Stunt detection only runs while the player is actively drifting
- Cooldown management prevents re-scoring the same zone too quickly
- Debug imgui panel allows spawning/removing zones and benchmarking performance
See Also
- drift/bounds - Drift Zone Boundary Detection - Related reference
- drift/destination - Race Path & Wrong-Way Detection - Related reference
- drift/display - Drift UI & HUD Management - Related reference
- Gameplay Systems Guide - Guide
Drift Statistics
Reference for `gameplay_drift_statistics`, which records drift performance metrics into the persistent statistics system (`gameplay_statistic`).
Freeroam Cruising
Reference for `gameplay_drift_freeroam_cruising`, which automatically shows/hides the drift angle UI when the player sustains a drift chain while in freeroam.