How-To: Run Game Phases

Goal: model warmup / playing / post-game as mutually-exclusive phases and run logic when one starts or ends.

Prerequisites
How-To: Get the Building Blocks step 4.

1. Create a phase ability

A phase IS an ability. Subclass UCrimsonGamePhaseAbility and give it a phase tag such as GamePhase.Warmup. Nested tags express sub-phases: starting GamePhase.Playing.SuddenDeath ends GamePhase.Playing.Normal but not GamePhase.Playing.

Right-click -> Blueprint Class -> `CrimsonGamePhaseAbility`, then set its Game Phase Tag in Class Defaults.

2. Start it and listen

Every phase call is authority-only
The subsystem's mutating functions are BlueprintAuthorityOnly. Calling them on a client silently does nothing - phases are game state, so drive them from the GameMode or GameState.

Get World Subsystem (CrimsonGamePhaseSubsystem) then:

  • Start Phase - takes the phase ability class and a delegate that fires when it ends.
  • When Phase Starts or Is Active - fires immediately if the phase is already running.
  • When Phase Ends - fires on exit.
  • Is Phase Active - a plain query.
Verify
Start a phase on the server and confirm Is Phase Active reports it, then start a sibling phase and confirm the first one ends.

See also

  • Concept: Global System and Phases