Part 4 : Gameinstance

Back to main post

According to the documentation : The GameInstance exists for the duration of the engine’s session, meaning that it is created when the engine starts up and not destroyed or replaced until the engine shuts down. A separate GameInstance exists on the server and on each client, and these instances do not communicate with each other. Because the GameInstance exists outside of the game session and is the only game structure that exists across level loads, it is a good place to store certain types of persistent data, such as lifetime player statistics (e.g. total number of games won), account information (e.g. locked/unlocked status of special items), or even a list of maps to rotate through in a competitive game like Unreal Tournament.

Step 1: Create a Blueprint GameInstance and BP Interface

Create Gameinstance and Interface
This image has an empty alt attribute; its file name is image-6.png
In Project Settings, Maps en Modes set Gameinstance

Step 2: Connect Interface to Gameinstance and make Reference

GameInstanceRef in Interface
Connect Interface in GameInstance
Game Instance Ref

Step 3 : Create Blueprint Widget and add Show MainMenu in Interface

Create Blueprint Widget

ShowMainMenu in Interface

Step 4 : Building the Widget

Designer Widget
Graph Widget

Step 5 : Event Show Main Menu in GameInstance

Add Variable MainMenuWB in GameInstance
Event Show Main Menu in Gameinstance

Step 6 : Open main menu from level blueprint

Level BluePrint

Video step 1 to 6

In the following video I forgot to show that in Project Settings, Maps en Modes, the Game Instance class is set to your created Gameinstance!!

Explaining first 6 steps

Previous steps are preparation for the real thing 🙂

Step 7 Create PlayerInfo Struct, Add to Interface, Store in GameInstance

Struct FD_PlayerInfo
SavePlayerInfo in Interface
In GameInstance add variable PlayerInfo and Event SavePlayerInfo

Step 8 Store to PlayerInfo in Menu. Event M to print PlayerInfo

In MainMenu store PlayerInfo to GameInstance
Event Key M in Level Blueprint

Video step 7 and 8

Step 7 and 8

Wrap up Part 4

Wrap Up Part 4


I have added another part, where on the Gameinstance al list of numbers is stored. This list is filled by the clients. In this case I used the character for getting access to the gameinstance of the server

Keys : G and H



Video with result extra

Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.