Pawn owners in multiplayer (c++)
I have two questions:
I need this so i can call a server RPC from a client. From my tests so far it seems that the pawn spawned when a player joins is owned by the server or is unowned and thus calling a server RPC from a client is dropped.
asked Apr 13 '19 at 02:18 PM in C++ Programming
I think you are mixing owner and controller
How controlling pawns and net communication in unreal works is over controllers. A player has a playercontroller and with that player controller he can posses a pawn to steer it.
If you have a pawn you can call GetController() on it to find out if anyone steers it. If you have a controller you can call GetPawn() to get the controlled pawn.
You have to be a little bit careful in multiplayer games only the server has playercontrollers for all players, the individual clients have only their own playercontroller.
RPC come in three flavours NetMulticast: from server to all clients Client: from server to the client who is controlling the actor Server: from client to server, (can only be called on actors controlled by the client making the call)
Additionally you can check the ownership of an actor by testing its net role. actor->GetLocalRole()
Results: ROLE_SimulatedProxy ..... You are on a client and the server has total control over it ROLE_AutonomousProxy ... You are on a client and you are able to call rpc server calls on it ROLE_Authority ..... You are on the server with total control
answered Apr 14 '19 at 12:08 AM
Ownership is who is own the client connection. It looks into the outer class of your pawn. Usually it finishes with Controller. Controller is created on clients. So client own the pawn
Ownership and authority is different.
Authority is who created the object ( normally server )
This assumption is wrong. Pawn is not owned by server. Server has authority over it. Pawn owner by client who own the network connection cite from http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
Follow this question
Once you sign in you will be able to subscribe for any updates here