How should I use my GameMode

Hello,

In my game my world is devided into several regions, in which the teams must capture all flags in one region in order to capture the entire region. Currently, I am doing all the calculations like who should be possessing (determined by amount of players from each team), capture progress, etc inside of my flag-actor. The same goes for my region-actor.

So far, this is what my flag-actor is doing:

  • Detecting players entering/leaving a fixed collision box around it and updating the amount of players from each team within this collisionbox
  • Calculating which team should possess (if team1 has 3 players inside of the collisionbox, and team2 only has 2, team1 would possess. If team1 and team2 both has equal amount of players it would be contested)
  • Calculating the progress (If owner of the flag possesses, secures the flag. If attacker of the flag possesses, captures the flag)
  • Also stores the variables which returns the owner and possessor of the flag

My region-actor is pretty much doing the same thing:

  • Detecting players entering/leaving a fixed collision box around it and updating the amount of players from each team within this collisionbox
  • Calculating which team should possess based on the amount of flags they own in the relevant region
  • Calculating progress of the possession (Securing, capturing)
  • Also stores a variable which returns the owner and possessor of the region

I was wondering what I should use my gamemode for in my case. Should I calculate the progress of possession in the flag- and region-actor or should I do this in gamemode? Should I store my variables which returns the owner, etc of the flags and regions in the gamemode? Etc.

As far as I understand it, gamemodes only run on the server, which means every variable and all information is automatically replicated to all the clients, right? And I don’t yet understand what should be controlled in the gamemode. Could anyone point me in the right direction please?

Thanks in advance :slight_smile:

~Stefan

The game mode does run on the server only - this means it’s variables can’t be replicated to clients since they don’t have copy of the game mode. For variables you want everyone to know (such as which team has possession of which flag/region), you should use the game state, which the server and clients have a copy of (with the server’s version being the authoritative version). Here, you can replicate variables and call RPCs, and clients will react accordingly.
The game mode essentially is there to define a set of rules, and the gamestate should keep track of how the game is progressing, with the server version being able to check the game mode for the rules to know when the game should be over or any other rules you want.
It can be a little confusing, but the gameplay framework is a solid foundation for any unreal engine game. I would highly recommend getting yourself accustomed to it through the official documentation here, and particularly refer to the Setting and Tracking the Rules of the Game section.

I really needed this, thanks for your help and explaining this to me! :slight_smile:

Glad I could help. Good luck with your project!