Gameplay
Overview
The GameplaySystem
provides a way to run high-level scene logic such as spawning players/enemies, evaluating win conditions and activating various parts of the scene. The system itself is very sparse, it mainly serves to tick the state machine implemented in GameplayController
where the actual logic is implemented.
Controller
Main gameplay logic is defined in the GameplayController
and can be extended by the user in GameplayController.User.cs
. The GameplayController
is an asset and is _required to run the Quantum simulation. This asset contains static EGameplayState
configurations (enter-exit state pairs and their duration). States can be also dynamically set from script at runtime, effectively overriding the static configuration.
The GameplayController
API includes:
OnInitialize()
: called once upon simulation initializationOnDeinitialize()
: called once upon simulation destroyOnEnterState()
: called when entering gameplay stateOnUpdateState()
: called every frame for a specific gameplay stateOnExitState()
: called when exiting gameplay stateGetNextState()
: called when the current state is about to finish, you decide next stateGetStateDuration()
: returns duration for a specific state
State Machine
The FPS Template implements these EGameplayState
:
Initialization
: Used for one time scene initializationWaiting For Players
: Waiting for players to send their data and create Player entity, spawning AI for missing players on the endGame Start
: Can be used for match introduction sequence, players overview, ...Round Start
: Short warmup sequence, countdown, ...Round Progress
: Main gameplay, time based, team elimination, ...Round End
: Short round winning/losing sequenceRound Replay
: Optional replay, last kill, best player of the round, ...Game End
: Final gameplay sequence, ending animation, ...Game Replay
: Optional replay, best moment of the game, MVP moments, ...Game Summary
: Showing match statistics, rewards, post match interactions, ...Deinitialization
: Cleanup
The following diagram presents the gameplay state machine's default flow:
Data
The data supporting the gameplay is saved in the GameplayData
asset. This asset contains baked data for a specific scene. By default the GameplayData
asset contains Waypoints and NavMeshLinks. It can be extended in GameplayData.User.cs
.