How to get level name in BP?

I know that you can do it using C++, but how to do it with blueprints?

I’m setting up a save game blueprint and need this to make it work. The idea is to save the level name as a variable, and then load the saved level name when the game is loaded.

Afaik there is no variable for that.

It could be complicated, especially for level streaming. Since one host level can load several others.

Haven’t tried, but each lvl can execute on load event and append name in array of loaded levels.

Since the only way to load level is provide it’s name - I don’t see any reason to make that variable hardcoded. Level - top element of hierarchy. It’s level who loads everything else. (I guess the chance of being inside of level that was mystically loaded is fairly low).

You will have to do this with C++ and create a custom node for now (as of UE4.6.1 there’s still no node).

To get the current level name:


But the level name is prefixed, depending where it runs (PIE, Window), so, in order to get the prefix:


Then you can perform a string replace removing the prefix and get the level name :slight_smile:

The .h file has…

	/** Get the currently loaded map reference name.   You have to have a sourceActor because multiple maps can be loaded/loading.
	* Typical return string is like "UIEPED_0_MyMapName" in the editor or "MyMapName" if in a stand-alone game.
	UFUNCTION(BlueprintCallable, Category = TDLHelpers)
		static FString GetCurrentMapReference(AActor * sourceActor);

And the .cpp is…

FString UtdlBlueprintHelpers::GetCurrentMapReference(AActor * sourceActor)
	if (sourceActor == NULL)
		return FString(TEXT("Must have a sourceActor (was NULL)"));

	return sourceActor->GetWorld()->GetMapName();

Hey, what do I put as the source actor?

The source actor is either the player actor, and then you get the top level.

If you are using tiled maps and the source actor is some tin can you dropped in the level, then the map will be the tile.


“SND R Keene”'s solution is fine but requires you to specify an actor, to remove this requirement:

// in the "meta" declaration add:
"WorldContext = "WorldContextObject"
// then in the method declaration pass the object
class UObject* WorldContextObject

This way you can get the level name without requiring an actor, like:


That’s it!

That is correct if you are in a single level with no tiles.

Tiles levels have multiple ‘maps’

One simple way to do this in BP without using C++ is make your own variable in GameMode and feed ;

Create your own GameMode;
Create a variable MapName into GameMode;

In your level blueprint / BeginEvent set MapName (make this all maps want to control)

Now to get map name only to do is call function:

get game mode → cast to your game mode->get MapName

1 Like

Hey, I’ve used SND R Keene’s first solution, have an actor (my game mode, where I’m using the get level code). It works great on the debug but for some reason it doesn’t seem to work on an executable. Any ideas as to why that might be/potential fixes for it?

Edit: Never mind. Found out what the problem was. When using the level finder in debug it stick udpie_1_before it (or something to that effect). I used a substring to remove this part which stopped it working on the executable. All I had to do was remove the substring code and now it works on he executable (but not on the debug).

Yes, but this solution is for tiled world maps. So there is an overall map, and then each sub-tile is a map.

We want to be able to load/unload and create new objects into a sub-tile.

Thanks for figuring that out.

U load the new tiles level manualy?
I never work with tiles map, but if u load, u can try set again mapname in gamemode.
For you know the exact name of each set of tiles you can create a structured object with Sub-tiles and your name so you get the whole load desired sub-tiles and the name of the same.

They get loaded automatically by Unreal as the player travels.

I know this is an old thread, but they recently added a ‘Get Current Level Name’ function to BP. I thought I’d leave this answer here for you and anyone stumbling upon this thread.

In fact this can be done via the BP-Interface.
In Level BP using the message from the input parameter BPI with Object, and through which pass a reference.

Very cool. I just found this as a much better way to get the level name as this parses it for you. It’s also in UGameplayStatics so it’s very accessible in C++ as well.

Love it. Here’s the shorthand:

FString mapName = GetWorld()->GetMapName().Mid(GetWorld()->StreamingLevelsPrefix.Len());

It’s a little hacky, but I just did this. All in bp. :smiley:

1 Like

Thanks dude you are life saver.