Download

How can I change levels in c++ code

Hi, I am trying to change levels using code and I am not able to do it.

I found some functions inside UWorld such has


GetWorld()->SetCurrentLevel();

But unable to make it work.

There is a BP Function called OpenLevel that you can use to load a new level, if you are looking to do so only on the client GEngine->SetClientTravel or you could use UGameplayStatics::OpenLevel which will call the previous mentioned function with proper level loading info and checks I recommend that if you are not using the BP

Thanks…

What are the FString Options?

You can actually look at the Menu Implementation of the StrategyGame sample.

In there you can see something like



GetWorld()->ServerTravel(FString("/Game/Maps/StrategyMenu"));


which will load the new level on the server and also sends the clients to the new level. (It also works if you dont have multiplayer actually).

Cheers,
Indy

Can someone say why GetWorld is undefined what do I need to include?