What I want to do
A Player is currently (alone) in a Lobby. The game is running as a listen server. Now he clicks on some start game button and the game executes:
void ALobbyGameMode::StartGame() {
bUseSeamlessTravel = true;
GetWorld()->ServerTravel(FString("/Game/Levels/Nordic_1"));
}
And a new map gets loaded. However, there still is the old UMG widget. The Lobby Player Controller (LobbyPC) has a reference to it and used to remove the when the Blueprint event “Event End Play” got called. But this event doesn’t seem to get called when using seamless travel. So I needed a new solution.
The Problem
I need to call a method on each clients Player Controller before the map is changed. So I looked in the documentation where it says:
The server will call APlayerController::ClientTravel for all client players that are connected.
So I looked at the APlayerController documentation and noticed that this function is not virtual. However there are the functions ClientTravel_Internal and ClientTravel_InternalImplementation, of which the latter is virtual. So I overrode it in my LobbyPC parent class:
void ALobbyPC::ClientTravelInternal_Implementation(const FString & URL, ETravelType TravelType, bool bSeamless, FGuid MapPackageGuid) {
if (GEngine) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Hello World!"));
}
ServerStartedGame();
Super::ClientTravelInternal_Implementation(URL, TravelType, bSeamless, MapPackageGuid);
}
The problem is: I neither see the debug message nor ServerStartedGame() is being called. Therefore I conclude this method ClientTravelInternal_Implementation is not being called.
Did I do/understand something wrong?
How can I remove the UMG widget before loading the new map and why is ClientTravelInternal_Implementation not getting called?
Thank you!