[UE5, Networking] Should this go into the GameMode?

About 20 youtube videos and 50 websites further I found that many people contradict eachother on what should go where. I’m a perfectionist, trying to get a clear understanding and I think what I said in my initial post, based on the references listed there, was wrong.

This makes a lot of sense, quoting a reddit user:

Reddit - Dive into anything

The Game logic, as far as I'm aware, should be stored in Game Mode. Game Mode is used for that because it is server-only and cannot be edited by the client, making it more resistant to cheating. Game State should hold variables like the score, but Game Mode should tell Game State what those variables should be and when they should change. 

If you are not doing any two way server - client instructions and clients simply can’t access the GameMode, this sounds a lot better than putting logic in the GameState.

Somewhat similar to MVC in web development, the GameState is the public Model, containing game related data shared to all players. It contains mostly / only data. The GameMode is the Controller, acting on a changing score in the GameState, spawning actors, executing game events. It contains the private logic and no / almost no stored data.

My initial posts looks like nonsense now :slight_smile:

Also in no situation should a player be allowed to do something like GameState->GetSomeManager()->DoStuff() because this should be server side only, it should be on the GameMode.

The idea is that the GameMode, being the server, performs all logic (such as scoring in soccer) and sets a score property on the GameState, which the GameState replicates down to players.


 3.6.1  GameMode

- Exists only on the server.
- Does not replicate.
- Acts similar to a Controller in MVC.
- Holds private game rules and all game logic, little to no data.
- Instructs a GameState when a rule is met.
- Writes game related public data to the GameState if relevant for all clients.

 3.6.2  GameState

- Exists on the server and all clients.
- Replicates down from server to clients.
- Acts similar to a Model in MVC.
- Holds public game related data relevant to all clients, little to no logic.
- Held data examples are match timer, team score, winning team, current cards in deck.
- Can be instructed by the GameMode to switch stage types such as lobby, start of match, end of match, score board.