PlayerController on Server and Client
In a multiplayer game, there is a copy of a player's PlayerController on his machine and on the server. I'm a little bit confused on how to tell whether functions on the PlayerController are called on the server or client (or both).
What about other functions on the player controller? Are they called on both the client and server? For example,
If it doesn't have "Server" or "Client" in the function name is it assumed that it's called on both server and client instances of the PlayerController?
asked Mar 12 '18 at 04:45 PM in C++ Programming
The function can be called on both the server and the clients, but where it will be executed it depends on whether the function is RPCs. Non-RPCs functions are executed where they were called. You have the RPCs function marked with the UFUNCTION() macro (see in the declaration) in which you have:
In addition, whoever calls this function is also important. It's best to see the table https://docs.unrealengine.com/en-US/Gameplay/Networking/Actors/RPCs. Usually, this function will have a server or client in the name. Read also descriptions of functions.
The PreClientTravel() function is not RPC (it will be executed where it was called) is called in ClientTravelInternal(), which is RPCs (Client type):
So where the ClientTravelInternal() function will be executed, the PreClientTravel() function will also be executed there.
To divide the code into a server and client, you can use:
answered Mar 12 '18 at 11:01 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here