Download

Is it possible to get a reference of client that runs RPC server in that function?

Hi, I posted so many times about this question on other sites but i haven’t got any of answers yet.

my question is that,

there’s a RPC server function and if one random client runs that function.

is it possible to get a reference of that client?

it’s listen server and all functions below are what i already tried.

GetPlayerController (if i use it in RPC server function, i can get only host’s Controller on the server side)

GetPlayerState (Host’s playerState)

GetPlayerPawn(Host’s Pawn)

so main problem is that, i can only get host’s info in RPC server. but i need client’s info that activated the RPC server.

Is there any way to solve it?

Does this answer your question? Actors and their Owning Connections | Unreal Engine Documentation

Ultimately, each connection has a PlayerController, created specifically for that connection […]. Each PlayerController that is created for this reason, is owned by that connection. To determine if an actor in general is owned by a connection, you query for the actors most outer owner, and if the owner is a PlayerController, then that actor is also owned by the same connection that owns the PlayerController.

Is this what you are looking for?

ENetMode NetMode = GetNetMode();
if (NetMode == NM_Client) { }

Just pass the player controller in the RPC

void ServerSomeRPC(APlayerController* CallingController);

then CallingController will be the controller of the client calling the RPC.

i thought if a client calls GetPlayerController in server RPC function, it indicates Host’s PlayerController but it turned out that it still calls Client’s PlayerController even in Server RPC.
it was just matter of dimension(Server and Client). ex)Client’s Controller on Server Side
after understanding the Server-Client diagram, i totally know why the problem happend! Thanks for all replies