in my PlayerController I want to bind to a delegate of my player character. First I thought to put this in BeginPlay() of the PlayerController but I noticed that in my networking game, the clients will not possess a pawn in their PlayerController when BeginPlay() is called.
Then I chose to override the void OnPossess(APawn* InPawn) function, but this one is actually not called on the ListenServer, I assume because the possession happens before the game starts.
So is there any reliable function call that will be executed in the PlayerController on clients and on the server when the PlayerController owns a Pawn? Or do I need to check it in both functions and make sure I don’t initialize twice?
I have created a custom method for my PlayerController though, which essentially combines OnRep_Pawn (only executed on clients) and OnPossess/OnUnpossess (always on server, sometimes clients when it feels like it). I use a HasAuthority check on OnUnpossess because the client doesn’t need to know about it anymore.