API ReferenceGE Extensionsgameplaydrift
Drift Zone Bounds
Reference for `gameplay_drift_bounds`, which detects whether the drift vehicle is inside defined zone boundaries and optionally draws them.
Reference for gameplay_drift_bounds, which detects whether the drift vehicle is inside defined zone boundaries and optionally draws them.
Overview
Loads site zone data from a file, checks the player vehicle's position against zones each frame, and flags out-of-bounds state. The drift display system uses this to show "Out of bounds" warnings and the scoring system uses it to freeze point accumulation.
Exports
| Function | Signature | Description |
|---|---|---|
onUpdate | () | Detect out-of-bounds, draw zones, run debug |
setBounds | (filePath, drawBounds?) | Load sites from file, enable/disable drawing |
getIsOutOfBounds | () → bool | Whether vehicle is currently outside all zones |
getDriftDebugInfo | () → table | Debug toggle state |
getGC | () → number | Garbage collection from profiler |
Internals
| Symbol | Purpose |
|---|---|
sites | Loaded sites manager instance |
isOutOfBounds | Current out-of-bounds flag |
drawBounds | Whether to render zone debug visuals |
profiler | LuaProfiler for performance tracking |
M.getDriftDebugInfo | () |
M.getGC | () |
M.getIsOutOfBounds | () |
M.onUpdate | () |
M.setBounds | (filePath, drawBounds_) |
How It Works
-- Set up bounds from a sites file (typically called by driftSpots or mission setup)
gameplay_drift_bounds.setBounds("/levels/west_coast_usa/driftSpots/spot1/bounds.sites.json", false)
-- Each frame, detectOutOfBounds() checks:
local zones = sites:getZonesForPosition(gameplay_drift_drift.getVehPos())
if #zones == 0 then
isOutOfBounds = true -- not inside any zone
end
-- Visual feedback: zones pulse red when out of bounds
-- Normal zones draw in white with filled interiorsKey Behaviors
- Uses
gameplay_sites_sitesManager.loadSites()to parse zone geometry - Zone drawing flashes red using
sin(runtime*2)for visibility - Out-of-bounds state is consumed by
gameplay_drift_general.checkFrozen()to freeze scoring drawBoundsdefaults totrueif not explicitly set tofalseinsetBounds- Only checks if
gameplay_drift_drift.getVehId() ~= -1
See Also
- drift/destination - Race Path & Wrong-Way Detection - Related reference
- drift/display - Drift UI & HUD Management - Related reference
- drift/drift - Core Drift Detection Engine - Related reference
- Gameplay Systems Guide - Guide