G2G Activity
Background activity that spawns random vehicles into the world. Uses a step-based sequence with fade-to-black transitions for vehicle spawning.
Background activity that spawns random vehicles into the world. Uses a step-based sequence with fade-to-black transitions for vehicle spawning.
Public API
| Function | Signature | Returns | Description |
|------
| M.dependencies | table | {"util_stepHandler"} |----
| M.activateFinished | () | nil | activateFinished ||-----------|
| M.onVehicleSwitched | onVehicleSwitched handler |---------|-------------|
| M.activate | () | nil | Starts the background activity, spawns vehicles |
| M.deactivate | () | nil | Removes all spawned vehicles |
| M.toggleActive | () | nil | Toggles activation state |
| M.isActive | () | boolean | Returns whether the activity is active |
| M.getVehicleOptions | () | table | Returns filtered list of eligible vehicle models/configs |
| M.onDeserialized | onDeserialized handler |
Dependencies
util_stepHandler
Vehicle Selection
getVehicleOptions() filters the vehicle list with these criteria:
- Type: Cars and Trucks only (no buses, no auxiliary)
- Performance: Must have top speed > 10 (excludes static/broken configs)
- Mode filters (hardcoded to
Default):Old Cars: max year ≤ 1985New Cars: min year > 1985Race and Rally: Config type Race or RallyRWD Only: Drivetrain == RWDOff-road: Off-Road Score ≥ 50
Returns array of {model, configs[], paints[]} entries.
How It Works
activate()builds a step sequence: fade-to-black → spawn N vehicles → fade-from-black- Each vehicle is randomly selected from
getVehicleOptions()with random config - Spawned vehicle IDs stored in
vehicleIdsfor cleanup deactivate()deletes all spawned objects from scene tree- Auto-deactivates on mission end and career start
Spawn Sequence
local sequence = {
stepper.makeStepFadeToBlack(),
stepper.makeStepSpawnVehicleSimple(model, config, callback),
-- ... repeat for vehicleCount
stepper.makeStepFadeFromBlack()
}
stepper.startStepSequence(sequence, finishedCallback)Hooks
| Hook | Purpose |
|---|---|
M.onUpdate | (empty - reserved for future updates) |
M.onClientEndMission | Deactivates on level unload |
M.onSerialize | Deactivates before Lua reload |
M.onCareerActive | Deactivates when career starts |
M.onVehicleSwitched | onVehicleSwitched handler |
M.onDeserialized | onDeserialized handler |
Notes
- Default
vehicleCountis 1 - Vehicle options cached after first call
- Uses
editor.onRemoveSceneTreeObjectsfor clean editor integration - Not persistent across serialization - always deactivates on save
| Function | Signature | Returns | Description |
|---|---|---|---|
M.activateFinished | () | nil | activateFinished |
Module Variables
| Variable | Type | Description |
|---|---|---|
M.dependencies | table | {"util_stepHandler"} |
See Also
- Gameplay Systems Guide - Guide
Walking
Reference for `gameplay_walk`, which manages the walking mode (first-person on-foot via the "unicycle" vehicle). Handles toggling between walking and driving, entering/exiting vehicles, proximity dete
Crash Test Boundaries
Reference for `gameplay_crashTest_crashTestBoundaries`, which manages spatial boundaries for crash test missions. Checks whether the player vehicle is inside designated zones and triggers out-of-bound