4.Managers

There are two main classes in the project responsible for managing the setup for the game including movement speeds, player lives, scoring rules and more.

The first class is the LevelManager which is responsible for exposing many of the important in game variables to the editor. However, it doesn’t manage the game during runtime, it provides the exposed variables to the GameMode class that acts as a kind of GameManager class.

Level Manager Roles:

  • Spawner Class Management - When the game first runs the LevelManager will search for any class of type Spawner. It will then make Interface calls to begin the spawning logic and timers.

  • Bounds - An in editor category to control the Out of Bounds collision wall details and the location for Disabled Pooled objects to be placed out of view ready for reuse.

  • Game Type Settings - Providing access specific GameType settings, utilised mostly to demonstrate the multiple demos for the plugin. The important values here are the GameTypeStartText and GameTypeLives. These are used by the GameMode class to provide a message to the game widget when the game starts with a start message and also set the maximum number of lives the player will get during play.

  • Float times - CountDownTime and RespawnDelay are both exposed for the editor here and used in the GameMode class during play to control how long the initial intro countdown into the level is and the time between respawning if player lives are available.

  • Level Speeds - InitialSpeed, MaxSpeed, SpeedAcceleration and the LevelMovementDirection are exposed for the editor and used mainly by the BP_SpawnableBase class and derived classes of that. They will check the speed variables and movement direction over time using interface getter functions from the LevelManager class to control the scrolling movement.

The second class used for game management is the BP_GameModeBase which handles many of the in game management of things like score, remaining lives and currency.

Rather than creating a separate Game Manager class the project makes use of the built in Game Mode class type which every game needs as part of the basic engine requirements. This does mean that the GameMode you select will need to be the BP_GameModeBase class found in the Common folder, or a child of that class.

Game Mode Base Roles:

  • Initialisation - This will reset the score, check for a game to load and update the player collected currency if there was something to load.

  • Game Variables - When the game starts, the GameMode will grab relevant information from the LevelManager from the exposed variables such as the player lives which will then be tracked and updated through the GameMode during play when the player dies.

  • Spawning/Respawning - The GameMode classes are responsible for spawning the player by default in Unreal and this is extended to also handle respawning a player class of a certain type when the player dies and remaining lives are available.

  • Game Flow - Handles the start and end of the game state as well as allowing for the game to pause and resume.

  • Save/Load - As well as loading the game when the game starts it will also save the game when the application ends play for any reason using “EventEndPlay

Last updated