The Game Instance
- Reference
- This is the "global scope" for the game.
- Looking at the reference
- This is spawned at game creation
- It is destroyed when the game is shut down.
- It has a large number of components
- And a very large number of functions.
- This is just one of multiple different "containers of this type"
- The GameMode is to hold the rules, only the server has access to this object.
- The GameState holds the state of the game, everyone has access to this object.
- The PlayerState holds information about the player, only the player has access to this object.
- I Believe the player state goes away when the player dies.
- I Believe the gamemode is per level.
- We will clean this up if we go to multi player games.
There seems to no hard fast rules where to put things.
But some gudiance is:
- GameInstance: persistant or data to store between levels.
Creating a game instance
- This is just a class, so you can make a new one.
-
- But then you need to make that your GameInstance.
- Project Settings
- Maps and Modes
- Set it.
-
Inside the game instance
- you can create variables, functions, macros, ...
- In this case, my game instance has two functions and three variables.
-
Accessing a game instance
- You can get the game instance with the GetGameInstance node
- You will probably need to cast this to the right type.
- In this example, my game instance is named GI_Instance
-