Quick way to disconnect client when quitting has server

void UPuzzlePlatformGameInstance::QuitToLobby()
{
	if (GameMenu) { GameMenu->TearDown(); }
	UEngine* Engine = GetEngine();
	if (!ensure(Engine)) { return; }
	Engine->AddOnScreenDebugMessage(0, 2, FColor::Green, FString::Printf(TEXT("Leaving...")));

	APlayerController* PlayerController = GetFirstLocalPlayerController();
	if (!ensure(PlayerController)) { return; }

	// if Server
	if (PlayerController->GetCharacter()->HasAuthority())
	{
		UWorld* World = GetWorld();
		if (!ensure(World)) { return; }
		World->ServerTravel("/Game/Maps/Lobby");
		return;
	}
	PlayerController->ClientTravel("/Game/Maps/Lobby", ETravelType::TRAVEL_Absolute);
}

In GameInstance.cpp

Privacy & Terms