Freeroam Drift Spots
Reference for `gameplay_drift_freeroam_driftSpots`, which manages freeroam drift zones - detecting when the player drifts through a start line, running the challenge, tracking scores/highscores, and i
Reference for gameplay_drift_freeroam_driftSpots, which manages freeroam drift zones - detecting when the player drifts through a start line, running the challenge, tracking scores/highscores, and integrating with the POI/big-map system.
Dependencies
gameplay_drift_general, gameplay_drift_drift, gameplay_drift_scoring, gameplay_drift_saveLoad
Exports
| Function | Signature | Description |
|------
| M.dependencies | table | { |----|-----------|-------------|
| detectStart | (lineId) | Check if player entered a start line while drifting |
| onUpdate | (dtReal, dtSim, dtRaw) | Main loop - check end conditions |
| onVehicleResetted | (id) | Improper end on vehicle reset |
| onGetRawPoiListForLevel | (levelId, elements) | Inject drift spot POIs and big-map markers |
| onDriftCompletedScored | () | Check objective completion, new highscore |
| onSerialize / onDeserialized | (data) | Handle hot-reload during challenge |
| getIsInTheConcludingPhase | () → bool | Post-challenge animation phase |
| getIsInFreeroamChallenge | () → bool | Currently in a drift spot challenge |
| getDriftDebugInfo | () → table | Debug toggle state |
| getGC | () → number | Profiler garbage |
Internals
| Symbol | Purpose |
|---|---|
lines | All start/finish lines loaded from drift spot data |
activeLine | Currently active line (during a challenge) |
isInFreeroamChallenge | Challenge active flag |
isInTheConcludingPhase | Post-finish animation phase |
options.concludingPhaseDuration | 2.5 s - end screen display time |
options.maxWrongWayDist | 5 m - wrong-way tolerance |
options.maxDistToIntendedRoad | 30 m - off-path tolerance |
options.stopTimeToAbort | 1 s - stopped vehicle abort time |
How It Works
Challenge Start
-- A start line is a rectangle in the world
-- Player must be inside rectangle AND drifting AND moving in startDir
gameplay_drift_freeroam_driftSpots.detectStart("spotName_lineOne")
-- If conditions met:
-- 1. Set context to "inFreeroamChallenge"
-- 2. Load bounds and race path
-- 3. Show tasklist with highscore and objectivesChallenge End - Proper
-- Cross the corresponding finish line (e.g., lineOne → lineTwo)
-- 1. Wrap up remaining score
-- 2. Show completion message with score
-- 3. Save score to leaderboard
-- 4. Reset to "inFreeroam" contextChallenge End - Improper
| Reason | Trigger |
|---|---|
wrongWay | Drove back up the course past max distance |
outOfBounds | Too far from intended road (>30m) |
stopped | Velocity < 2 m/s for > 1 second |
vehReset | Player reset vehicle |
Score & Objectives
-- Scores are saved per spot with license plate and timestamp
addNewScore(spotName, score)
-- Keeps top 10 scores, sorted descending
-- Objectives are defined in spot info:
-- {id = "bronze", score = 500, rewards = {bmra = 10}}
-- Career rewards are granted on first completionPOI Integration
-- Each line becomes a POI with:
-- 1. driftLineMarker - invisible trigger at line position
-- 2. bigmapMarker (lineOne only) - icon, name, preview, highscore
-- Uses "mission_drift_triangle" icon
-- Shows quickTravelPosRotFunction for teleportingKey Behaviors
- Each drift spot has two lines (lineOne, lineTwo) - either can be start or finish depending on direction
- Line crossing uses
isPointInsideRectangle()with local-space OBB test + velocity dot product for direction correspondingLineNamemaps lineOne ↔ lineTwo for finish detection- Marker objects (cones, etc.) are hidden on load via
scenetree.findObject - Score saving uses
gameplay_drift_saveLoad.saveDriftSpotsScoresForSpotById() - New highscore flash only triggers once per challenge (
hasAlreadyShownNewRecord)
Module Variables
| Variable | Type | Description |
|---|---|---|
M.dependencies | table | { |
M.detectStart | (lineId) | - |
M.getDriftDebugInfo | () | - |
M.getGC | () | - |
M.getIsInFreeroamChallenge | () | - |
M.getIsInTheConcludingPhase | () | - |
M.onDeserialized | (data) | - |
M.onDriftCompletedScored | () | - |
M.onGetRawPoiListForLevel | (levelIdentifier, elements) | - |
M.onSerialize | () | - |
M.onUpdate | (dtReal, dtSim, dtRaw) | - |
M.onVehicleResetted | (id) | - |
See Also
- drift/freeroam/cruising - Freeroam Drift Cruising UI Toggle - Related reference
- Gameplay Systems Guide - Guide