Changing levels, C++

I found some good examples on changing levels using Blueprints, but there isn’t much out there on doing it in code. All I’ve found is this thread that mentions GEngine->SetClientTravel or UGameplayStatics::OpenLevel:

But it’s not clear what those functions do, exactly. Do they destroy all the actors on the old level or do I need to do that? Do they reset all the state in the engine, etc? I’m just trying to figure out the general procedure for changing levels. Obviously, there is some data that I want to keep and some data that needs to be destroyed with the level.

I’m bumping this slightly old thread because I really need to know this.

Maybe I should ask a more general question: Does anyone have an example C++ project that includes changing levels?

I searched the templates (4.7 and 4.8) for things like “OpenLevel” and “ServerTravel” and found nothing.

The more I try to get it working, the more pieces seem to be missing. I get the feeling that I’m asking the wrong question or searching for the wrong thing because this is such a fundamental thing that I’m trying to do and there is no sample code to be found – not even in Rama’s code wiki. The only thing even semi-relevant that I can find there is this:
Game_Instance,_Custom_Game_Instance_For_Inter-Level_Persistent_Data_Storage

The client calls ClientTravel to join a server initially. After that the server will call ServerTravel to move it and the clients to new maps.
OpenLevel just changes map locally.

Also, as far as the objects are concerned, everything in a level gets destroyed on OpenLevel (all objects in previous map) and new are loaded. This included game mode. The character, player controller, player state etc. are all actually created on the server and replicated back to you, so a level open is a clean sheet. What I have found out stays are the widgets though, so be sure to destroy them before the travel. ServerTravel, as far as I know, makes all clients reload worlds (in the same way, and destroy all content) but does not destroy player controller and player state (not sure about the character).

Thanks, guys.

I’m also noticing that input settings aren’t reset. So if you want your various game modes to have different input setups, then you’ll need to manually clear them and remap them. Not too painful.