Replicating switching pawn possession

I am trying to have the server (GameMode) switch which character a client is controlling while keeping the old character alive.

Switching character possession works when it’s done on the listen server’s player controller or when the server destroys the previous character prior to telling the client’s player controller to possess the new character.

I tried editing pawn.cpp as was shown here, but the issue still occurs. I’ve also started trying to use ReplicatedUsing in my player controller to pass a reference to the character, but it seems that there has to be a more direct approach, especially since OldPawn->Destroy() makes Client->Possess(NewPawn) replicate perfectly.

Thank you for any help you can provide.

I’m still having this issue, though have found a temporary solution. I found that if MyGameMode delays calling possess (Using GetWorldTimerManager().SetTimer) on a newly created pawn, possession replicates and works for clients.

Is there a better way to force the GetWorld()->SpawnActor to replicate before the MyController->Possess call replicates?

Thank you! I add the same problem and this solved it.

Okay, I was having the same problem, and sure enough adding a delay before possessing the new pawn worked. Has anyone figured out why this is happening and if there is a better solution?