gedamial
(gedamial)
April 6, 2016, 1:44pm
34
The code from the ShooterGame is called on Server OR Client.
If EquipWeapon gets called, it checks if the one who called it is the Server or a Client.
If it’s the Server, we can directly equipped the Weapon via SetCurrentWeapon , if it’s the Client, we call the ServerRPC ServerEquipWeapon to get to the ServerSide
and then call EquipWeapon again, which will now end up in SetCurrentWeapon .
Your version would only work if the Server calls it. Clients wouldn’t be able to call that method.
That’s the difference. ShooterGames function can be called by the Client and will then be moved over to the Server.
Why? Because that’s how replication works. Only the Server can set Replicated Variables. If the Client would set the Weapon by itself,
no one would get the replication. That’s why he tells the Server to do that.
As explained above, NO, your method is not the same and will produce a different result.
You told me that each player in a Multiplayer game runs both the Server and the Client.
So when my EquipWeapon() function is called, both the client and the server will run into that…and I can easily block the client and make the server keep going through the function… or maybe not?