FD PlayerState

Back

Names in project : FDPlayerState (C++), BP_FDPlayerState (BP)

C++

Tasks :

  • Has the FDPlayerInfo which goes with the client
    – Set FDPlayerInfo

Share Button

FD GameState

Back

Names in project : FDGameStateBase (C++),

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

Back

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

C++

Tasks

  • 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

Back

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

C++

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

back

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

Back

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

Back

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

https://docs.unrealengine.com/en-US/ProductionPipelines/ScriptingAndAutomation/Python/index.html

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.

Scheme

Step 1: Create widget FD_ChatWindow and FD_ChatText

FD_ChatWindow:

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