API ReferenceGE Extensionsscenario
Position Goal
A scenario goal that checks if a vehicle is within range of a target scene object at race end. Used for parking/braking scenarios.
A scenario goal that checks if a vehicle is within range of a target scene object at race end. Used for parking/braking scenarios.
Internal State
| Field | Type | Description |
|---|---|---|
M.instances | varies | Assigned as {} |
Public API
| Function | Signature | Description |
|---|---|---|
M.init | (scenario) | Parses position goals from scenario JSON |
M.processState | (scenario, state, stateData) | Checks distance to endpoint on race result |
M.updateFinalStatus | (scenario, instance) | Reports final goal status to statistics system |
Goal JSON Schema
{
"goal": {
"position": {
"endPoint": "brake_zone_marker",
"purpose": "fail",
"msg": "scenarios.braking.notInZone"
}
}
}| Field | Type | Default | Description |
|---|---|---|---|
endPoint | string | required | Name of scene tree object to check distance to |
purpose | string | "fail" | "fail" or "win" - result if outside range |
msg | localizedString | "Not in brake area" | Message on trigger |
How It Works
initcollects all goals withid == "position", validates and defaultspurpose- On
onRaceResult:- Finds the
endPointobject in the scene tree - Calculates distance between vehicle and endpoint
- If distance >
endobj.scale.x(uses X scale as radius):- Triggers win or fail based on
purpose
- Triggers win or fail based on
- Otherwise: sets
result = "passed"
- Finds the
Usage Examples
-- Braking scenario: must stop within the marked zone
{
"vehicles": {
"scenario_player0": {
"goal": {
"position": {
"endPoint": "brake_target",
"purpose": "fail",
"msg": "scenarios.braking.missedTarget"
}
}
}
}
}Key Notes
- Distance threshold uses the endpoint object's
scale.xas the acceptance radius - Only checked at
onRaceResult- not continuous monitoring - The endpoint must exist in the scene tree (
scenetree.findObject) - For continuous position monitoring, use
distancegoal instead - Time string is appended to win messages but not fail messages
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
No-Move Goal
A scenario goal that fails if a vehicle moves from its starting position. Used for parking/brake scenarios where a vehicle must remain stationary.
Quick Race
Handles the runtime logic for quick race scenarios: vehicle spawning, prefab loading, waypoint generation from race paths, lap timing, highscore recording, and time-of-day setup.