Hey everybody,
most of you might know, that I’m in love with Multiplayer things. That’s why I wrote my Network Compendium.
Today, I gave someone on the Discord Server some help, while he was fighting with the “Blueprint Multiplayer” tutorial on the Unreal Engine Youtube Channel.
He posted me some screenshots and I was kinda confused by what I saw.
Before we start, I want to make something clear:
I really appreciate the work and time you put into these Tutorials and I do not want to talk down peoples work here, but if you create learning resources, then please try to make as less mistakes as possible.
There is a really high that I made mistakes in my Compendium, but I gladly correct them if someone tells me about them. So that’s why I’m telling you now, what’s wrong with this series.
##################################################################
Let me show you some examples of what is wrong.
Example #1:
As Networking is something where you really need to pay attention to stopping players from cheating, UE4 provides us with things like “Switch Has Authority”.
This node triggers “Authority” for the Server and “Remote” for the Clients. Using this is great, but it should be used at the correct places.
To further get into the example, the “GameMode” class is a Server Only Class. This means, not a single Client (despite the ListenServer, which I count as the Server here) has an Instance
of this Class. It simply does not exist on the Clients. Using “GetGameMode” on a Client will simply return a so called “nullptr”.
Why is that important? Let’s get back to our SwitchHasAuthority Node:
Would we need this node in the GameMode?
Answer: No, because without an instance, no one can call this function anyway (despite the Server of course).
Now let’s look into the LobbyGameMode, created in the video number 15:
Can someone tell me why this is used here? I’m 99.99% sure, it’s not needed and teaching this is wrong. Of course you need to use it, but not here.
Let’s go further with the GameMode.
Example #2:
RPCs, or so called “Remote Procedure Calls” are used to shift a function call over to the Server, the Client or (to keep it simple).
This is done with a ServerRPC, a ClientRPC or a Multicast.
To call a ServerRPC, we need to be in an “Client Owned” instance of a replicated class. An example for this would be the PlayerController, the PlayerCharacter or the PlayerState.
These classes accept ServerRPCs.
Back to the GameMode. Remember, it does not exist on the Clients. Would a ServerRPC be here of any use?
Answer: No, because there is no Client that could call it.
Let’s go back to video number 15:
So again, why do we need this here?
We also see something else in this picture:
Replicated variables. Why do we need to replicate variables here? There is no Client instance! Nothing to replicate things to!
Then, it’s not even some random variable, it’s an array of PlayerControllers. So let me update the knowledge about PlayerControllers:
The Server has an Instance of any PlayerController. Means, his own, and one of each Client. Clients on the other side, only have their own. They have 1 single PlayerController.
This means, even if we could replicate here, there would be nothing but ONE single PlayerController in this array for the Clients.
So why do we do this?
One other little thing is: Why is PlayerInfo stored in the PlayerController that Clients have trouble accessing?
Why not correctly teaching that it belongs into the PlayerState Class, that every Client can easily access via the GameState’s PlayerArray?
The Class even has a premade PlayerName and Score variable and everything can be correctly replicated.
Example #3:
What do we know about Widgets? Widgets are classified as Client Only classes. This means, only the Clients need to know about them and we should never do any logic in them
that drives GamePlay (in most cases). So looking back at the RPCs, would a ClientRPC make sense here?
Does the Server have an Instance, which is replicated, on which the RPC can be called? No, it doesn’t, a ClientRPC is not needed at all.
Still, this here is in video number 12:
Where is that called? In the PlayerController, locally, already on the Client. There is no need to call a ClientRPC here, yet it is said that we “want this to be on the owning client”.
##################################################################
I could probably go on with this list, by searching through the rest of the videos, but I don’t have a lot of time today.
So what should be done now? Well, in my eyes, this series should be taken offline and should be redone.
And before you do this, get someone who knows exactly what’s going on in the multiplayer framework of UE4.
And again, I don’t want to talk down your work. I know this all costs a lot of time and I really like that you address it, but I am totally NOT fine with
the way it’s done. This needs to be correct, small mistakes are totally fine, but this explains your own Engine wrong. And that on the official channel.
The thing is, that we community people, who do this stuff in our free time, need to remove all these wrong learned things out of the community again.
So back to the person who had trouble while learning with the series and who came to the Discord Server to ask for help.
He is now learning things that are unnecessary, if not even wrong and I might need to explain to him what things he doesn’t or shouldn’t need to do.
Thanks for your time and for reading this.
Cheers,