API ReferenceGE Extensionsscenario
Distance Goal
A scenario goal that monitors the distance between two vehicles and triggers win or fail when distance thresholds are exceeded.
A scenario goal that monitors the distance between two vehicles and triggers win or fail when distance thresholds are exceeded.
Internal State
| Field | Type | Description |
|---|---|---|
M.instances | varies | Assigned as {} |
Public API
| Function | Signature | Description |
|---|---|---|
M.init | (scenario) | Parses and validates distance goals from scenario JSON |
M.processState | (scenario, state, stateData) | Checks distances each tick; triggers result |
M.updateFinalStatus | (scenario, instance) | Reports final goal status to statistics system |
Goal JSON Schema
{
"goal": {
"distance": {
"target": "ai_vehicle_1",
"maxDistance": 50,
"minDistance": 5,
"distanceEnable": 30,
"purpose": "fail",
"msg": "scenarios.myScenario.tooFar"
}
}
}| Field | Type | Default | Description |
|---|---|---|---|
target | string | required | Name of the target vehicle to measure distance to |
maxDistance | number | optional | Fail/win if distance exceeds this value |
minDistance | number | optional | Fail/win if distance drops below this value |
distanceEnable | number | optional | Only start checking after getting within this distance |
purpose | string | "fail" | "fail" or "win" - what happens when triggered |
msg | localizedString | auto | Custom message on trigger |
How It Works
initfilters goals forid == "distance", validates numeric types- Each
onRaceTick, calculates distance between the goal vehicle andtarget - If
distanceEnableis set, waits until player is within that range before checking - Once enabled, checks
maxDistanceandminDistancethresholds - If exceeded, calls
showMsgwhich finishes the scenario as win or fail - Also supports
scenario.targetNamefor scene-object distance checks (legacy)
Usage Examples
-- In scenario JSON: fail if player gets more than 50m from escort target
{
"vehicles": {
"scenario_player0": {
"goal": {
"distance": {
"target": "escort_vehicle",
"maxDistance": 50,
"purpose": "fail",
"msg": "scenarios.escort.tooFar"
}
}
}
}
}
-- Chase scenario: enable distance check only after getting close
{
"distance": {
"target": "chase_target",
"distanceEnable": 30,
"maxDistance": 100,
"purpose": "fail"
}
}Key Notes
- Uses
helper.getVehicleByNameto find the target vehicle object distanceEnablecreates a "proximity activation" - goal inactive until close enough- Both
maxDistanceandminDistancecan be used together for a distance band - Falls back to
helper.getDistanceBetweenSceneObjectsfor legacy scene object tracking
See Also
- Scenario Bus Driver - Bus Route Scenario Logic - Related reference
- Scenario Damage Goal - Damage-Based Win/Fail Condition - Related reference
- Scenario Demolition Derby - Last Vehicle Moving Wins - Related reference
- Scenario System Guide - Guide
Demolition Derby
A simple demolition derby scenario mode where the last vehicle still moving wins. Tracks all scenario vehicles and declares a winner when only one remains in motion.
Drift Goal
A scenario goal that calculates drift scores from vehicle angle and speed, supports combo chains, and triggers win/fail based on minimum drift score thresholds.