I am trying to do some cleaning before ClientTravel is called since for some reason the client crashes if its pawn is still there when ServerTravel is being called. Looking at the documentation and the APlayerController.h header file, there is this function PreClientTravel which should be called before any travelling takes place. Thing is in my case it is not being called at all. I added debug messages to it and they are not displayed in the client. nor they appear in the logs.
So anyone has any idea why this function would not be called? Do I have to call it myself? BTW, I use seamless travel, in case this might have something to do with this issue.
My PreClientTravel:
void AECOBasePlayerController::PreClientTravel(const FString & PendingURL, ETravelType TravelType, bool bIsSeamlessTravel)
{
UE_LOG(LogTemp, Warning, TEXT("PreClientTravel was called."))
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, TEXT("PreClientTravel was called."));
/// Get the possessed pawn
APawn* ECOPawn = AController::GetPawn();
/// Only if we have a possessed pawn do we attemp to destroy it before travelling
if (bIsInLobby)
{
if (ECOPawn)
{
UE_LOG(LogTemp, Warning, TEXT("Possessed pawn is not nullptr"))
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, TEXT("Possessed pawn is not nullptr"));
ECOPawn->Destroy();
}
bIsInLobby = false;
}
}