Hello. First of all HAPPY NEW YEAR!
On a less happy note I’ve been having some issues with game sessions and getting the data correctly replicated to all the clients. Let me show you some code.
This is what I’ve got on my GameMode’s PostLogin:
void ALobbyGM::PostLogin(APlayerController * NewPlayer)
{
UE_LOG(IntruderDebug, Verbose, TEXT("PostLogin - Begin"));
Super::PostLogin(NewPlayer);
if (!HasAuthority()) { // Authority Only
return;
}
ALobbyPC* lobbyPC = Cast<ALobbyPC>(NewPlayer);
if (!lobbyPC) {
return;
}
// init the lobby PC widgets
lobbyPC->InitialSetup();
lobbyPC->SetupLobbyMenu(ServerName);
RespawnPlayer(NewPlayer);
UE_LOG(IntruderDebug, Verbose, TEXT("PostLogin - End"));
}
And here’s what I get on the Server’s log when a client joins :
[2017.12.31-17.04.14:668][ 72]IntruderDebug: Verbose: PostLogin - Begin
[2017.12.31-17.04.14:669][ 72]IntruderDebug: Verbose: RespawnPlayer_Implementation - Begin
[2017.12.31-17.04.14:670][ 72]IntruderDebug: Verbose: RespawnPlayer_Implementation - End
[2017.12.31-17.04.14:670][ 72]IntruderDebug: Verbose: PostLogin - End
[2017.12.31-17.04.14:670][ 72]LogNet: Join succeeded: DESKTOP-2MMA877-4230
[2017.12.31-17.04.14:700][ 74]IntruderDebug: Verbose: CallUpdate_Implementation - Begin
[2017.12.31-17.04.14:700][ 74]IntruderDebug: Verbose: SwapCharacters_Implementation - Begin
[2017.12.31-17.04.14:700][ 74]IntruderDebug: Verbose: CallUpdate_Implementation - End
The issue here is that all those calls that are logged after the LogNet: Join succeeded line are made inside InitialSetup. Therefore they should be called before the RespawnPlayer, not way after.
It’s not just the logger that has the info on the wrong order. The RespawnPlayer call is doing all kinds of wrong stuff because the NewPlayer has not been initialized when it gets called.
Why are the calls being made in the wrong order?
Is PostLogin not the correct function to call here?
Is the fact that InitialSetup is a UFUNCTION(Client, Reliable) making it wait? But why is RespawnPlayer not waiting for InitialSetup to be over before executing?