How to reset level in C++?
does anyone know how to easily reset the level in C++? I thought there would be a function that does that inside the UWorld class, but I couldn't find any.
I also tried this "hack":
But it doesn't seem to work either (any idea why?)...
// Edit: playerController->ConsoleCommand(TEXT("RestartLevel")); seems to do the trick, but whats the clean way of doing this, that also works in a multiplayer game?
If this is a standalone game and maybe multiplayer server.
You can do the following command with ?restart.
ClientTravel( TEXT("?restart"), TRAVEL_Relative );
void ClientTravel(const FString& URL, enum ETravelType TravelType, bool bSeamless = false, FGuid MapPackageGuid = FGuid());
This how the controller does it in the codebase. Hope that helps :)
Okay, so maybe this one will help you under your
AGameMode::ProcessServerTravel(const FString& URL, bool bAbsolute)
and make sure that you have bUseSeamlessTravel set true;.
Actually the more I look, it seems that
void UWorld::SeamlessTravel(const FString& SeamlessTravelURL, bool bAbsolute, FGuid MapPackageGuid)
Is what you want. The information in World.cpp has some great info and says it doesnt' disconnect the clients. :)
Follow this question
Once you sign in you will be able to subscribe for any updates here