They just make sure, that no Client can call that Function.
You could, in fact, structure your own code a way, that you wouldn’t need authority checks.
But you will find yourself often at the position where you want to make sure that really only the Server can call that function.
A simple example is:
Something needs to be done on the Server and you have a ListenHost and Clients using one and the same Function.
The Server/ListenHost can directly do the stuff you need, but the Client needs to call the RPC.
That’s when you might want to check with Authority who exactly called the function.
But yes, at this point, the Authority check is made to make sure that no Client can call this.
The function is probably not even called on a client. It’s just for anti cheat safety stuff.
Well, you can have execution chains that never touch the Client. That happen on Server only, but you still want to
limit the Call to the Server, since a Client could call that function when cheating.
A Server RPC is just to get the Call from Client over to the Server. You don’t want to use a Server RPC to ensure that
it runs on the Server. You only use ServerRPCs if something happens on the Client and it must move over to the Server.
For example a KeyPress or a Button Press in UMG.
**ServerRPC: **
When things that happen on the client should be communicated to the server to make it execute something.
Example: the player kills someone, and the kill counter in the leaderboard should be updated
(uhm, not kinda sure… the client may still call the function by cheating and increasing his own kill-counter, right?)
AuthorityCheck:
When something MUST be called and executed on the server.
Like making the server add a weapon to a player’s inventory.
One is an RPC call that moves the call to the Server, Client or Multicast (3 different types of RPC).
The other one is to check if the instance, which is calling the function, is running on the Server or the Client.
There are even more checks, for example if it’s a dedicated server or not.
For example: Dedicated Server don’t need a UI, so you can make sure the UI spawning logic is only called on ListenServer
and Clients.
Authority Checks are not about calling something. They are more about making sure that only a specific kind of authority can
use a specific function.
A Server RPC would mostly not be used to update the Leaderboard, since the whole killing should only happen on the Server.
The Client only gets the visual effects.
But pressing “Shoot” (left mouse button) is a client action and needs a Server RPC to actually handle the shooting and replicate it.
But then when I start the game and in the BeginPlay I print a DebugMessage, why does the DebugMessage gets printed as many times as the number of players?
To execute that function exclusively on the client I’m controlling, I should use a RPC-Client call then?
@eXi Also, it looks like for each player there’s a server… look at this:
BeginPlay is called on every instance of that Actor. I don’t know what Actor you used there, but as an example:
The PlayerCharacter in a Multiplayer Game with 2 Players (ListenHost and Client).
The Server has a PlayerCharacter. This one exists on the Server and replicated on the Client.
The Client has a PlayerCharacter. This one also exists on the Server and replicated to the Client who owns it.
So in total, there are 2 copies of the Server PlayerCharacter and 2 copies of the Client PlayerCharacter.
BeginPlay is called 4 times at this point. You limit it to the Authority (Server). That means you get 2 calls, one
for the Server Version of the Servers PlayerCharacter and one for the Server Version of the Clients PlayerCharacter.
If the Server only had one Character instead of one for each Client + himself, how should the rest of the network game
see his Character? Every player has an instance of the Character of the other players. Otherwise they wouldn’t be able to see each other.
It’s not an RPC because if the client called that function, it would tell the Server to destroy the inventory (and it would work, because ROLE on the server would be authority).
That completely depends on where you call “something”. If you do that in the BeginPlay, then yes, it might get called on every Server Instance of that Actor.
But if you have a single ServerRPC, it will only get called on the Server Version of that one Player who called the ServerRPC.
I can only recommend you to watch some more tutorial videos and maybe read the docs a bit more and, in the end, just play around with what you learned here.
The point is there’s no enough documentation about Networking.
Speaking about videos, on YouTube there is ONLY one playlist about Networking.
Speaking about Unreal Documentation, yes they speak about the basic things of multiplayer… but doubts constantly come to my head.
Other than the ShooterGame, there’s no more precious source for learning UE4 + Networking in C++.
Anyway,
Look at this:
When I jump, both the DebugMessage gets printed on both the client and the server windows.
Even if I change the RPC call to be a ServerRPC instead of a ClientRPC…** same things happen.
**
Is that a problem related to the AddOnScreenDebugMessage()???
Yo, that could be due to PIE sessions running in one single process. Messages might appear on both screens, even if they are only called on
one of the Players. If you really want to know if it’s Server or Client, use the
And you don’t need C++ to learn networking. Blueprints and C++ work the same. You know how to code, so that’s not the problem.
Download the Multiplayer Shootout Game or my “BallBump” project (can be found through my Signature in the Free Projects thread) and
check out how the networking works in these. It’s not different to C++, despite the way to actually “write” a function instead of a BP node.
But the logic stays the same.
I know the feeling. It is sort of feast or famine for the C++ networking world and ue4. Shooter game and Tom’s stuff are awesome! But there really isnt much out there in c++ where you start from scratch and build up to something like Tom’s or the shooter game.
There is a C++ Mp shooter on the marketplace, i haven’t bought it yet, but it might help?
When the player takes the Pickup, the OnPickup() function is called.
I want the SERVER to manage the Pickup and edit the bIsActive variable (which determines if the pickup is visible or not)
So for that purpose I do the RoleAuthority check
AFTER I’m sure that it’s no longer the client, but it’s the server that keeps going through my function, and so calls the NetMulticasted function Tell_PickupPicked() to tell ALL the clients the pickup has been taken.
All the Tell_PickupPicked() function does is what I want it to happen ON ALL THE CLIENTS, and so: print a debug message, hide the mesh, start a rspawn timer and set it’s variable bIsActive to false.
But none of these happens.
I know my logic is extremely wrong, but help me find out why!
I feel so stupid about Networking, but not Networking in general… but with UE4 in particular.