FD GameState


Names in project : FDGameStateBase (C++),


Tasks :

  • Has PlayerArray with all connected clients
    – Print Connected Players
    – Check if Player is Already Online
  • Has FDPlayerInfopArray with PlayerInfo for each connected player
    – AddFDPlayerInfoArray
    – Remove FDPLayerInfoArray
    – PrintFDPlayerInfoArray
  • Set Number Of Players from Gamemode in Screenmenu
    – On Rep Number Of Players

Share Button

FD GameMode


Names in project : FDGameModeBase (C++), BP_FDGameModeBase (BP)



  • Keeping Track of the connected PlayerControllers
    – OnPostLogin
    – OnPostLogout
    – SetNumberOfPlayers
  • Sent message to new client about login
    – Login Message to Client
  • Distribute chat message’s to all connected Players
    -Update Chat to all clients
Share Button

FD GameInstance


Names in project : FDGameInstance (C++), BP_FDGameInstance


Tasks :

  • Handling the Menu’s
    – Show Main Menu
  • Writing and Reading Json files from disk (server)
    – SavePlayerInfoToDisk
    – Init : read and fill username and password from disk
    – Write Logbook Json
    – Write Chat Json
    – Write Json Base Files
    – Receive Login Name : Check of LoginName exists as UserName, if yes : sent FDPLayerInfo to client

Share Button

FD Information Flow


The different flows of information in the project.

Information will be stored on the server, by using Json.

  • Login and User strategy.
    PlayerInfo will be in a Jsonfile on the server. The prototype will not have an add usersystem in Unreal. This will all be done in the JsonFile.
    Username will be unique identifier of each user.
  • PlayerInfo
    Stored and retrieved from server (GameInstance). Json Files
    When a player connects with the server, PlayerInfo is copied to the PlayerState.
    For example : Username (unique), Password (not copied to PlayerState), Full Name, University / company, email, class / group, avatar settings, previous avatar settings?, Timestamp?, last visit, time online.

  • Achievements player or group of players
    Stored and retrieved from server (GameInstance). Is copied to PlayerState and with groups to the GameState.
    Assignments made by students and group of students.
  • Storytelling / gamification
    This is probably going to be most important part in the future. In the prototype this is going to be most important part in the future. In the prototype this is going to be very simpel. Scavenger hunt
    Still a lot of research needs to be done
  • Chat Text
    From Client to PlayerController to all clients.
  • Voice chat
    Is out of the box available in UE?
  • Online Calculator
    Input Calculator should be visible for the other avatars looking at the calculator
    Information goes through GameState
  • Data FD_Watersurface, FD_Sewer, FD_Sea, FD_Rain
    These have to do with the watersystem on the island, most of these Blueprints / C++ .
    Most of them make complex calculations (velocity, waterlevels, discharge, waves, energyline, pressureline, …)
    Basic idea is that all calculations are made on the server.

    Note : The hole watersystem on the island is connected, often some change can have effect on the hole system . But sometime this is not the case, so maybe a set of rules can be made (GameMode) to determine of a change leads to a recalculation of the complete system of only a part.
  • Movement of the players / avatars
    Is multiplayer out of the box.
  • Shape of the avatars
    Configuration of each avatar will be stored on the server.

Chat text:

Share Button

FD Framework


In C++ map Framework :

  • FDGameInstance
  • FDGameMode
  • FDGameState
  • FDPlayerState
  • FDPlayerController
  • FDCharacter

In Blueprint Framework

  • BP_FDGameInstance
  • BP_FDGameMode
  • BP_FDGameState
  • BP_FDPlayerState
  • BP_FDPlayerController
  • BP_FDCharacter

In Blueprint Interfaces

  • BPI_FDGameInstance
  • BPI_FDGameMode
  • BPI_FDGameState
  • BPI_FDPlayerState
  • BPI_FDPlayerController
  • BPI_FDCharacter

Share Button

FD Software-Plugins-Settings


Software :

  • Visual Studio Community 2019 16.8.4
  • Visual Assist (optional)
  • Specifier Tool (optional)
  • Unreal Engine 4.26.0 build from source, branch release
    Note : When compiling, errors will occur which are related to the experimental chaos system. Still you can run the engine and compile projects

Plugins Built-In Engine

  • Landmass
  • Water
  • Editor Scripting Utilities
  • DataSmith

Plugins from marketplace

  • Linter , at the moment the version for 4.25. Works ok with 4.26

Settings :

  • Editor Preferences > Asset Editor Open Location = Content Browser
  • Editor Preferences > Source Code Editor = Visual Studio 2019
  • Editor Preferences > Editor Performance > Show Frame Rate and Memory
  • Project Settings>Performance > Enable Performance Log
  • Project Settings>Framerate>Smooth Frame Rate>checked
  • View Option (Downside screen)
    -Show Engine Content
    -Show Plugin Content

Share Button

Python Part 1 : Setup basic project.

Step 1 : Create new project UE 4.25.4. From architecture .. , blank, with starter content, no raytracing, no BP.

From learn : https://learn.unrealengine.com/course/2436632/module/5367573?moduletoken=UHxxnDLPW8Q5KSe4aguQ3gEEpywFgqqAzh6V1R2ea4tXGNsf7prUPDq~vgBaxSsF&LPId=0

Make sure the python and datasmith plugin’s are selected


Share Button

Part 7a Gamemode with chatbox

Back to main post

We are going to create a chatbox on all clients.
All steps are also explained in a video at the end.
Note : When building you sometime have to go back and forth.


Step 1: Create widget FD_ChatWindow and FD_ChatText



In grap add variable IncomingText which Exposes on Spawn
Bind IncomingText to Text Block

Step 2 Add FD_ChatWindow and chatbutton in MainMenu.

Add ChatWindow and chatbutton
Blueprint Chatbutton

Step 3 : Blueprints FD_Chatwindow
You first have to make some events at the playercontroller

Blueprints Chatwindow

Step 4 : Add mainmenu in playercontroller, delete from gameinstance!

Disconnect ShowMainMenu in Level Blueprint ThirdpersonExampleMap
Add variable ScreenMenu and Load MainMenu in Playercontroller

Step 5 : Gamemode

Blueprint Gamemode

step 6 : Playercontroller

ProjectSettings > Input > add binding chat enter

Binding chat with enter
Blueprints Playercontroller

Video explaining

Video demonstration chatbox

Extra : Adding the mainmenu through the gameinstance.

I did not like my solution, where I added the mainmenu widget in the playercontroller instead of from teh gaminstance. Ofcourse both solutions are correct, but I want to keep the menu widgets on the gameinstance. So I made the next corrections.

Reconnect in level blueprint thirdpersonexamplemap
In gameinstance use Event show main menu
in playercontroller, this part is not needed anymore
Changed event UpdateChatWindow in playercontroller

If you run, you will get the same result. In my opinion the second solution is more consistent with the idea to keep the menu’s on the gameinstance

Share Button

Lessons learned

Back to main post

So what did I learn? With focus on the dedicated server.

  • Replication to clients only works when it is set on the server.
  • Often you read the word clients, this is misleading. With characters and playercontrollers for example there is 1 server and 1 client!!. So you can not get access to all clients with a playercontroller or character.
  • My biggest misconception was that if you use for example the switch Has Authority , with authority you can’t get acces to the remote / client by using an custom event or the other way around. Example of how it really works

So the branch is set to client, but by using the event SetNameOnServerGI (runs on server) one gets access to the server anyway!!. Although the branch is set on client!!

Same when you set branch or switch to server, you can get access to the client by using an event which is “Runs on owning client”

  • A widget (menu) lives only on the client, a gamemode lives only on the server. So you need a for example a playercontroller (lives on server and client) to get a widget (menu) to communicate with a gamemode.
  • Probably I use reliable to often.
  • A menu widget can get acces to the gamestate client, but not to the gamestate server.
    You need to use the playercontroller (event run on server) to get something done on the server side of the gamestate from a menu widget.
  • If a variable is replicated and changed on the server side of the gamestate, it is visible for all clients!
  • To get access to player state in menu widget, you have to use the playercontroller
  • In the gamemode you can change the playername in playerstate.

Share Button

Part 8 : Gamestate and PlayerState

Back to main post

According to documentation: The GameState exists on the server and the clients, so the server can use replicated variables on the GameState to keep all clients up-to-date on data about the game. Information that is of interest to all players and spectators, but isn’t associated with any one specific player, is ideal for GameState replication. As an example, a baseball game could replicate each team’s score and the current inning via the GameState.


According to documentation: A PlayerState will exist for every player connected to the game on both the server and the clients. This class can be used for replicated properties that all clients, not just the owning client, are interested in, such as the individual player’s current score in a free-for-all game. Like the PlayerController, they are associated with individual Pawns, and are not destroyed and respawned when the Pawn is.


For this part I will make a little game : Collecting coins.
At the start there are for example 1000 coins in the bank. Each player can collected coins. When there are no coins left in the bank, the game is finished. Each client gets a message showing the coins collected by each player.

Although it looks a bit overdone for such a small game, I used gamemode, gamestate and playerstate:

  • Gamemode : Setting the max coins in the bank (1000)
  • Gamestate : Calculating collected coins by players and check if coins in bank are finished.
  • Playerstate : Tracking number of coins collected by player.
  • Playercontroller : used for connecting menu widget with gamestate and playerstate.

In the next screenshots I show the final blueprints, when building you most likely need to go back and forth.

Note: I only used the interface of gamestate and playerstate to get a reference.
I should have used more functions going through the interface.

Step 1 Create Gamestate, create interface, create reference

Step 2 Create PlayerState, create interface, create reference

Step 3 Add Gamestate and Playerstate to you gamemode!!
At first I had forgotten to do this 🙁

Step 4 Changes to the mainmenu

Added : PS Get List, PS Print, Add Coins, Print Coins, Start Collection Coins
PS Get List
Ps Print
Add Coins
Print coins
Start Collecting coins
Add change player name in playerstate add the end of continuebutton

Step 5 GameMode

Event SetNameInPlayerState. This is the way to change the playername of the playerstate.
Function GetCoinCount
Variable Maxcoins

Step 6 GameState

Variable TotalCoinsCollected
Blueprints Event Graph
On Rep Coins Left
On Rep Game Finished
On Rep Start Game

Step 7 : PlayerState

Event Print Name Player State and variable CoinsCollected
Increase coins
Several blueprints

Step 8 : Playercontroller

Most of the events in the playercontroller are necessary to connect the menu widget to the gamestate and playerstate. So they are called from the menu, to get something done in the gamestate or playerstate

Blueprints Playercontroller

Step 9 : BP_Pickup

Changes made to the existing BP_Pickup. In the first event you should add an has authority switch, to make sure coins is only set on the remote. The dedicatie server has no coins (has no graphical interface). At first I got a warning in the dedicated server log.

Blueprints Even graph and variable NumberOfCoins
Added textrenderer and RotatingMovement

Step 10 : New Blueprint with cube (only one) called BP_Cube

Blueprints Event graph

Result when running in multiplayer

Share Button