How to load umap file?

Hi, Guys

I am a newbie to Unreal4, Wanna build a automation test to check whether the Game has loaded the Map, If not, load it. I can use the GEngine to get the UWorld and MapName. But I do not know how to load a new Umap file in C++. I have tried the AutomationOpenMap function, It does not work. Could you guys please help me about that?

Thanks.

By loading umap file do you mean loading the package in memory or just open it to play?

Hi Sveitar,

I just wanna open it to play. Do you know which function I should use?

Thanks

The simplest way is to use UGameplayStatics::OpenLevel

#include "Kismet/GameplayStatics.h"

void YourClass::YourMethod()
{
    UGameplayStatics::OpenLevel(GetWorld(), "YourMapName");
}

Let me know if this was what you were looking for.
And don’t forget to mark the answer as correct.

Enjoy!

By the way, UGameplayStatics class is a blueprint library. You will find most of the blueprints exposed static methods there. Take a look at the header file, there’s plenty of functions that serves as shortcuts for doing lots of things.

Enjoy!

May I ask a silly question? What is the default file path the OpenLevel uses? Thanks.

I have tried it, but it react nothing, I do not saw the map being changed something…Could you please teach me in detail? I am totally newbie to Unreal…