Help understanding multiplayer framework

To start I read down through the network compendium by Cedric ‘eXi’ Neukirchen and still have a few questions I cant seem to find answers to. I have been trying to understand the higherachy of network flow because I am tired of brakeing down and having to rewrite projects. I either end up putting something in the wrong place or not understanding the best place to replicate variables from.

Up till now I have been putting almost everything into the player pawn say like the variable that contains all the objects in the players inventory that the server usually controls. In the compendium however it had a thing about the player state that if the player disconnects it can keep those variables for when they reconnect. Now I have heard these things depend on the type of game your trying to make and what type of multiplayer it is and so on. I figured I would be able to find a tutorial on the best practices but as of yet I have not the information is spread out or doesnt exist.

Alrighty well I could write a blog with all the questions I have on this subject. So I would like if anyone knows a tutorial or a more in depth description on the best practices for dealing with multiplayer flow control. I mean this really should be a thing like I just learned that you can use a function in game mode using the player controller to change the players name. Now I could only access this variable from the player state but if you look up the node for change name other than where to find it; almost nothing exists to tell me how best to use it. I had a chat system I copied from a tutorial where they made a custom variable on the controlled pawn for the player name and set that. Now while that works as you can see these functions already exist but without a best practices thing to help dev’s find these simple things already built in they get missed.

The tutorial dosent need to be super extensive like the compendium some basic knowlage of coding would be expected. Just go into details of what these (game instance, game mode, game state, player state, player controller, and controlled pawn) are best used for and how to utilize what’s already built in. As I would assume depending on what your doing in single player these will mostly be utilized in multiplayer games since there isnt much light shed on them in many of the tutorials.

Oh also something on smooth gameplay would be soooooo helpful like how to do something client side and then do basicly the same thing server side and overite the relivent info on the client side. Best example I have which is a problem I am dealing with at the moment is I want to drop an object from the player inventory. Now without going into to much detail about the code I spawn the object client side to keep it smooth so the player if say is lagging a little bit doesnt have a brake in game play. Then I spawn the object server side and multicast to everyone that this was spawned. This however spawns 2 of the same object for the owning client and what I’m looking for is the server side to overwrite the object the client spawned. This is just one example but I have come to believe it’s best practice to do it this way. It seams to get either ignored, overshadowed or not even considered when people make tutorials on multiplayer mechanics.

Anywho before I drone on to much longer I really hope someone can point me in the right direction. In my opinion this should help people and possibly make games more stable having a clear idea of best practices and use what’s already there.

I agree that it’s a bit hard to find a tutorial covering all the gameplay framework classes and where they each fit in a multiplayer context with some example code and implementation. Since you mentioned PlayerState though I recommend checking out the Multiplayer Shootout sample project which has [good documentation][1] discussing [how PlayerState is used][2], in addition to how other gameplay framework classes are set up and the overall networking flow. You can download this project from the Epic Launcher under the Learn tab. Hope that helps.

I’ll deffinantly give it a shot. Doing google searches for this info I mean depending on the wording is just daunting. I keep coming across nodes that have little to no description and classes that could be better utilized if all there basic functions were explained. I wish to find more info like how the youtuber Mathew Wadstein lays it out; thanks to what ever diety for that person. If only the documentation was as complete.
Anywho if that example explains most of what I was wondering I’ll mark this as answered if not I’ll either make a more narrowed down question or edit this one

Alright so the project while it had comments to explain the functionality of its code it didn’t really explain why the code was there. I went and searched this project and found Blueprint Multiplayer Shootout Game | Live Training | Unreal Engine - YouTube and also Multiplayer Shootout | Unreal Engine Documentation These 2 links helped but still didn’t answer why they were using the classes that they were using. The live stream felt so janky they really should script these things. They should have a clear idea of how to explain what they want to explain and not stumble through the whole thing like oh we should talk about this.

Anywho other than how to use networking code to set up a multiplayer session this didn’t really help with how you should structure your workflow and utilize the classes in multiplayer. This is a perfect example however of how spread out this information is and that I wish there was a more strait forward in depth explanation.

Also this project is kinda old a lot more functionality has been exposed in blueprints and they didn’t really do anything at all with the player state class. The player state only had a small function in it no other code and they didn’t really even talk about it in the live stream.

I use PlayerState only for replicated variables that other players need to know about that doesn’t belong in the Pawn/Character.

Changing the name from a client is done with the PlayerController function SetName. It is not exposed to Blueprint but you can call it with “Execute Console Command”.
The server can also change the name using the GameMode function ChangeName.
Last but not least a client joining a server can provide the server with its name through the a OpenLevel Option key called Name. This is useful for quickly setting the name up when a player connects instead of having the player submit its name post login.

GameMode only exist on the Server and is therefore the place to do Server only stuff. GameState is replicated to all clients and is used when the Server GameMode needs to make an announcement to all the clients through a Multicast RPC or replicated variable.

Overall when making a multiplayer game you will have an easier time if you know some C++ since there is a lot of useful information hidden here that isn’t exposed to Blueprint.

“I use PlayerState only for replicated variables that other players need to know about that doesn’t belong in the Pawn/Character.”

While this does make sense what are generally things that you would put in here? You dont need a full list but some examples would help. It also doesn’t make sense because there are functions to restore a players state in certain scenarios; one example I gathered was if they disconnect and reconnect. Basicly that to me hints that it’s important for this class to have access to variables you want to be maintained in certain events and not just for replication.

“Changing the name from a client is done with the PlayerController function SetName. It is not exposed to Blueprint but you can call it with “Execute Console Command”.”

This is nice to know though I haven’t worked with console commands. However I was thinking more along the lines of variables and functions you don’t have to dig to find. If you bring up the node drop down when you right click or bring up the class defaults. Using these what would you say is the reason these classes were created and in the workflow process how best should they be utilized.

“The server can also change the name using the GameMode function ChangeName.”

This is in the networking compendium but it is listed under the player state. Which I have found out and as your post lists it’s actually in the game mode class and you need to pass in the controller to use it. However I found out that the variable it is setting is in the player state or at least if you want to access it you need to go through the player state. Using either the variable player name or the function get player name which for some reason I find the function to be more reliable. There is however basicly no documentation on this seemingly simple thing that should be well known and documented. Which is the whole point to why I made this post for things like this.

“Last but not least a client joining a server can provide the server with its name through the a OpenLevel Option key called Name. This is useful for quickly setting the name up when a player connects instead of having the player submit its name post login.”

This last piece here confused me only because I looked at the open level function. Now while it did have an options string you could pass in the documentation as usual gives no guidelines as to what you can or should pass in. https://docs.unrealengine.com/en-US/BlueprintAPI/Game/OpenLevel/index.html I however did find this post which expanded on the subject https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/55949-openlevel-with-options

Server only stuff is pretty broad for the reasons of this thread. The game state also from some of the things i have seen feels like it has more functionality then to just make broadband announcements though this is a good function for it.

“Overall when making a multiplayer game you will have an easier time if you know some C++ since there is a lot of useful information hidden here that isn’t exposed to Blueprint.”

I have done quite a bit of searching for the differences between blueprint and regular C++. The way the editor keeps updating though more functionality keeps getting added to blueprint. At this point with out an in depth look and probably a spreadsheet. There doesn’t seam to be much difference between to two and honestly I find more trying to argue that one is faster than the other without giving any hard statistics to the point. All this is irrelevant as I am trying to understand the full functionality of blueprint and not what you cant do with them vs regular code. Also even if you know C++ that doesn’t mean your going to know the full functionality of each blueprint class. The dev’s who made unreal made these classes for certain purposes or at least I would hope they did. They filled them with these variables and functions to fulfill those purposes. In the end what are those purposes so that they can be utilized properly. I am trying in this post to understand because the documentation is pretty lax on specific details when it comes to this utilization. This creates to broad a net and for the people like me having trouble connecting the dots this creats problems. Examples might be bugs because things are not were they should be or people having to write code to fulfill functions that they ignorantly don’t know are already built in. I want to know even if someone only explains 1 class and then someone explains another how to best utilize each class. To explain that these functions or variables are in these classes to fulfill these purposes.