OnNetworkFailure called repeatedly after host quits

I noticed by printing out a log statement that when ConnectionLost occurs the OnNetworkFailure will be called continuously while the map is still loaded. Loading the menu did not work, but causing a ClientTravel then loading the menu ensured it was only called once.

void UPuzzlePlatformGameInstance::OnNetworkFailure(UWorld* World, UNetDriver* NetDriver, ENetworkFailure::Type Type, const FString& ErrorString) 
{
    UE_LOG(LogTemp, Error, TEXT("Network Failure Occurred: %s"), *ErrorString);
    if (Type == ENetworkFailure::FailureReceived || Type == ENetworkFailure::ConnectionLost) 
    {
         APlayerController* PlayerController = GetFirstLocalPlayerController();
         if (!PlayerController) 
         {
             return;
         }
         PlayerController->ClientTravel("/Game/UI/MenuSystem/MenuLevel", ETravelType::TRAVEL_Absolute);
         LoadMenu();
     }
}
2 Likes

@wirepair That is perfect! Thanks for sharing it mate. <3