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.
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?
/**
* Travel to a different map or IP address. Calls the PreClientTravel event before doing anything.
* NOTE: This is implemented as a locally executed wrapper for ClientTravelInternal, to avoid API compatability breakage
*
* @param URL A string containing the mapname (or IP address) to travel to, along with option key/value pairs
* @param TravelType specifies whether the client should append URL options used in previous travels; if true is specified
* for the bSeamlesss parameter, this value must be TRAVEL_Relative.
* @param bSeamless Indicates whether to use seamless travel (requires TravelType of TRAVEL_Relative)
* @param MapPackageGuid The GUID of the map package to travel to - this is used to find the file when it has been autodownloaded,
* so it is only needed for clients
*/
UFUNCTION()
Thanks, this works perfectly in singleplayer, but in a multiplayer match in the editor this results only in a respawn of all playercontrollers and in a standalone game its even worse, it results in a disconnect of all clients.
I am calling the function on the listen server as well as on all the clients.
Also, I just found a ServerTravel function in the UWorld class.
However, GetWorld()->ServerTravel(TEXT(“?restart”)); doesn’t seem to work (clients get disconnected)…
and make sure that you have bUseSeamlessTravel set true;.
/**
* perform map travels using SeamlessTravel() which loads in the background and doesn't disconnect clients
* @see World::SeamlessTravel()
*/
UPROPERTY()
uint32 bUseSeamlessTravel : 1;