-
-
Notifications
You must be signed in to change notification settings - Fork 8
[U] Game mode
The UVK::GameMode
class is entirely owned by a level and contains pointers to a Game State
, Player State
and a `Player Controller
- Generate a game mode using the Build Tool (for this example it's going to be called
GM
) - Include the game mode header into your level's header
- In the constructor call, add the following line with the type of your game mode class as a template argument:
gameMode = GameMode::makeGameMode<GM>();
- You have a game mode for your level
To use the game mode's events in your level, call the void beginAutohandle()
, void tickAutohandle(float deltaTime)
and void endAutohandle()
in their respective functions void beginPlay()
, void tick(float deltaTime)
, void endPlay()
. This will call all the game mode's events when one of those events is triggered.
Semantically, the game mode should be used to store the rules of the game and possibly manage them
The game mode class provides a static Pawn* getPawn(GameMode* gameMode)
function to easily access the pawn without navigating down the hierarchy
The game mode owns pointers to a GameState
, PlayerState
and a PlayerController
. The same "autohandle" events apply here to call the events of all these classes.
You can use the standard cast
function to cast a pointer to a game mode to its original type, like this
gameMode = GameMode::makeGameMode<GM>();
auto* a = GameMode::cast<GM>(gameMode);
This project is supported by all the people who joined our discord server and became beta testers. If you want to join the discord you can click here
- Home
- Beginner concepts
- Advanced concepts
- Engine developer and contributor resources