[Help] Multiplayer Game - Mode, State, etc. Please help me understand the process.

Hello all! Thank you for taking the time to read this, I have spent a while reading docs and videos, and I’m still totally confused :frowning:

Here is what I am looking to accomplish:

  1. Player launches the game and is presented with a login / register screen.

  2. Player logs in (Nevermind the register for the scope of this question)

  3. Player gets a Main screen with a menu (play, options, credits, etc)

  4. Player clicks “Play” and is given a list of servers. This list will contain servers dedicated and perhaps user hosted.

  5. Player selects a server and joins that game.

To add a bit of explanation, think of it as World of Warcraft if you are familiar. You opened the game and logged in. You then selected a Server (Called a Realm) and clicked Join Server and you were entered into that servers game.

So, I am confused. I am finding my way, and I can do mysql login easy enough, I’ve got that working. What I’m needing to know is, what is the best way to handle all of the user’s information. There will be “Global” information such as player name, global ban status, achievements, etc. There will also be “Local Server” information such as Health, Guild, Inventory, etc. It seems this would imply a handoff at some point(s) but I’m not sure.

The specific information that I need is a theory of how to accomplish this along with how and when to use the GameMode, GameState, PlayerState. I am so confused. If I launch the game and use GameModeOne (example name) for the login and main menu, etc. Do I still need to use GameModeOne for the actual servers game? Or can I use GameModeTwo? How would I securely (Prevent cheating, exploiting, etc) pass data between them?

I would like to keep this all in blueprints. Thank you for any input.

The only way I know of storing information in Blueprint is Save Game. And I don’t think you would want to make a MMORPG with Save Games to handle player information. But I’m not sure about this (you may have other ways in Blueprint only). And of course, you can do anything you want in C++.

This was only regarding the way of storing information and if I’m correct you’re not specifically asking for this. You’re asking how to handle a MMORPG data flow in your game. When and how to load stuff.

Well, you have several layer of information about your player: Account and Character at least.

Account is about your name, settings and character list.
Character is about one character name, talent choices and gear.

I’m exposing a pretty basic example here, depending on the complexity of your game you may have a lot more layers or information density inside one layer. But let’s assume that’s what we got.

You’re asking in what Game Mode you should be exposing stuff.

The logic is pretty simple here: you’ll basically have to implement your loading logic in a way that you don’t have to implement twice in two different places of your code.

You usually have a Game Mode for outside the game and one for inside the game. This may look like OutGM will load Account informations and InGM will load Character information. But in that case you end up being Ingame without your Account information. So we want InGM to also load Account informations.

The logic would be that OutGM and InGM are both child classes of MainGM which loads Account informations.

You then have both GM loading meaningful information in the current state of your game.

Regarding cheating-security I can’t help you, I don’t know much about it.

Think of Game Modes as a specific set of rules for a given slice of your game (Outgame & Ingame for instance).

For each slice you have, you’ll supposedly need a Game Mode which tells the player which Player Controller to spawn (and each of these controllers will be told to spawn a different HUD).

Regarding Game State, it’s all about dividing your game slices into smaller slices. To give you an example in a competitive FPS game like Overwatch. You start off at spawn, it’s one Game State (that has one specific rules: players can not generate energy). When timer is over, gates are opened and we’re switching to another game state “Match”. When one team wins, we’re switching to a last game state “EndMatch” with Play of the Game and scorescreen.

I don’t think you would want to use GameStates at your stage of development. Besides that, GameStates are used to store game information we want clients to be able to read (they can’t read information in your GameMode). So you often end up with your GameMode communicating a lot of stuff to your GameStates. In Overwatch’s case, we can assume the current score of both teams is stored in their GameState.

PlayerState is also an actor used mostly to allow clients to retrieve information about other players. You might think PlayerState and PlayerCharacter are overlapping with each other (you want to store the same kind of information in both of them) but in reality, you can ask yourself a simple question to know where a variable should be: is the variable tied to the Character? If so, it should go in your Character code. A simple example would be a game where you switch between different characters but you earn experience points for all of them. Experience would be in your PlayerState and Health would be in your PlayerCharacter. Another good example is the Player Name, which is typically not a variable tied to your Player Character (except if you’re displaying the current Character Name and not the Player Name).

We often use PlayerState in OutgameMode where players tend not to have a Player Character alive in the scene.

I’m having trouble picturing your setup because I’m not used to MMO / dedicated server setup. But to me it could look like this:

Once connected to the Server:
MainMenuMode → Server-side since we’re on the GameMode, when a player connects, it loads its data and sends him, it reads your Realm List and sends him
MainMenuGameState → At this stage, it does nothing, you might have a “MultiplayerLobbyGameState” which would handle current connected players
MainMenuPlayerController → Spawns your Main Menu HUD and receives the data from the GameMode, loads in the Character and Realm List in the Main Menu HUD
MainMenuPlayerState → At this stage, it does nothing, you might have a “MultiplayerLobbyPlayerState” which would handle your name, selected character…
No player character

Once loaded the game map:
IngameMode -> Loads account data and retrieve character list, load chosen character
IngameState -> Maybe handle stuff like guilds
IngamePlayerController -> Retrieves data from GameMode
IngamePlayerState -> Maybe handle stuff like grouping / current quests / Account Inventory
IngamePlayerCharacter -> Retrieves data from GameMode, handles stuff like Health / Character Inventory

I realize my post is a big mess. But I just write as I thought about things. Let me know if you have specific questions (quote me :)).

GL HF on your Sunday everyone :slight_smile:

Excellent response! Thank you!