Delay between server pawn possession to owner client pawn being possessed?

Hi guys! When the server spawns our player and gives the pawn possession we trigger a event Possessed in our player BP, then we call a replicated function to the owning client telling the client that it has been possessed, then we call a C++ function to setup the players playable objects and its inventory and UI. In our notification replicated function, if we do not put a delay before calling the local setup player C++ function, the C++ function will return early before setting up the placable objects and setting up the UI, because IsLocallyControlled() returns false. If we put a delay there it will return true because the possession apparently takes a bit of time to reach the local player. Is there a way to verify that the local player has been possessed? Preferably having something event based so that we don’t have to do continual checking to make sure that we have been possessed before we check if the player is locally controlled.

here is a pic of the BP

Thanks!

Hi there,

Event Possessed in your pawn fires only on the server. But the possession progress is actually not 100% complete yet.

You can be sure, that the server now knows about this possession, but this information must still be replicated to the client(s).

Here some Code snippets of the PlayerController::Possess function: (I have UE 4.12.5)

    		PawnToPossess->PossessedBy(this);
    
            [...]
    
    		SetPawn(PawnToPossess);
    		check(GetPawn() != NULL);
    
    		[...]
    
    		ClientRestart(GetPawn());

The PawnToPossess->PossessedBy(this); part is what actually triggers your Event Possessed you know from your blueprints. However this possess is only known serverside and will not be triggered on the client.

However the function goes on and at the end makes sure, that the client received the possession and also restarts the pawn on the client.

ClientRestart(GetPawn()); then triggers in the pawn the function Restarts;

So for now I overwrite

public:
	virtual void Restart() override;

in my pawn to signal e.g. my UI that it has to update itself/get new references.

One option I still have to further investigate is the OnRep_Pawn() Function in AController.

Although I might stick stick with Restart from Pawn since I can be sure there, that the pawn is actually acknowledged.