So far I’ve been working on a lot of things unrelated to networking and level building, but I want to change that.
Simplified, this is what I learnt about these classes:
gamemode (Server)
- Holds private game rules.
- Pulls and verifies replicated data from the GameState.
- When a rule is met to switch to the next game “stage” it will instruct the GameState to do so.
gamestate (Server + Client, replicated)
- Tracks and replicates data relevant to the GameMode’s rules such as team scores, match timer.
- Holds stages (Lobby, start of match, end of match, score board).
I find myself questioning where the level related logic has to go. Think of Left 4 Dead which has a “Director” class which manages when and where zombies will spawn in a level. This Director would be private, server side only (GameMode?) but it’s spawns are replicated (Spawn handling in GameState stage?).
Makes sense. But what about zombie spawn positions? Zombie classes? They differ per level. Does this make sense?:
- GameMode provides GameState with data assets (zombie classes, spawn positions)
- GameMode instructs GameState to start “match” and timer.
- GameState keeps track of timer and replicates it to others.
- GameMode pulls timer data from GameState, after 2 minutes (private rule) it instructs GameState to spawn zombies of class A to position X, which automatically replicates them to all players.
What code do we do in the level? So far I have written absolutely 0 code in any of my levels, I just use them to place actors, meshes and other visuals, not logic. If for ease of editing you would add “spawn points” of zombies to a level and pass that data to the GameMode or GameState you create a circle between classes, this can’t be right.
Also I saw some awkward implementations of two way client server communication with RPC I don’t currently see the value of. It seems wrong if you at any point have to check your system’s authority within an Actor to switch between code, or have to validate client requests where the server should be leading in the first place?
References:
Networking Overview for Unreal Engine | Unreal Engine 5.1 Documentation
Multiplayer Network Compendium | An Unreal Engine Blog by Cedric Neukirchen
What should I do in GameMode, GameState, and PlayerState? - #2 by Raildex