Download

Possession Doesn't Update Controller on Network Client Actor

Having the server possess an actor with a client controller does not update the actor’s controller variable on the client.
This is because APawn::PossessedBy is not replicated.

Why isn’t possession replicated?

What is the proper way to possess an actor with a client’s controller?

EDIT:
Aaaah, apparently this is an old issue. Thanks Google!

Okay, that post wasn’t my issue. My issue was that for some reason APlayerController::ClientRestart_Implementation gets called super late and I’m trying to access the controller too early.

On a general note, doing things on possession on a client is super hard. Multiple things have to happen to get the client actor ready to go and they can happen randomly.

After hours I’m still not sure where to put the code that is supposed to run on the client when an actor gets possessed.

character pawn has possessed and unpossessed events.

Make function that tells you are running code on client, standard has authority, will lie to you when you run client code on linsten server. That may cause some weird moments.

I also found out that for replication and communication to server and other clients best is PlayerState. It is lite version of player controller that exists on all clients and server.

In UE 4.11 they added the following:

New: Added “PostRepNotifies()” event to Objects, called after any rep notifies may be triggered.

This is going to solve all my issues since it is only called once your object has been fully replicated!
Very cool!