Systems and Components
Gameplay
The main system for controlling gameplay is the GameplaySystem
. It is responsible for controlling the gameplay loop (waiting, start, progress, finished), player spawn, AI spawn, calculation of race positions and checkpoint passing.
The Gameplay
component triggers RaceStarted
and RaceFinished
events.
Vehicle System
The VehicleSystem
is in charge of updates to the car physics components - specifically, Vehicle
and Steering
- as well as checking for vehicle collisions and triggering the VehicleCollision
event which results in visual spark effects on the Unity side.
The Vehicle
component is responsible for applying physics forces to the car entity and solving wheel ground collisions. The Steering
component on the other hand is responsible forthe car rotation based on the steering input.
Player
The PlayerSystem
updates the Player
components.
The Player
component prepares InputDesires
, processes the checkpoint passing, periodically checks an entity’s driving line position (used for AI and race positions) and is holding the player states (HasStarted
, Finished
). It also handles the vehicle resetting back to the track. The Player
component is added directly to the car entity.
When a checkpoint is passed, the Player
component triggers the CheckpointPassed
, WrongCheckpoint
, LapFinished
or PlayerFinished
event.
Pickup System
The PickupSystem
updates the pickups in the world (Nitro) and is responsible for checking if a player is passing through a pickup.