Pawn owners in multiplayer (c++)

I have two questions:

  1. I want to know who is the owner ,or how to determine it, of the pawn that is spawned when a player joins a session.

  2. How to set the owner of an actor. I know that you have to use SetOwner() but which actor do you actually
    pass to this function.

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.

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

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 )

From my tests so far it seems that the pawn spawned when a player joins is owned by the 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

PlayerController is the first Class that thePlayer actually ‘owns’, but what does that mean? Each Conn> ection has a PlayerController, created specifically for that Connection. A PlayerController,that is created for that reason, is owned by that Connection. So when we determine ifan Actor is owned by someone, we actually query up to the mostouter Owner and if thisis a PlayerController, then the Connection that owns the PlayerController also owns that Actor.