# How to get level name in BP?

**URL:** <https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083>\
**Category:** World Creation\
**Tags:** Map, unreal-engine, Blueprint, question\
**Created:** [October 24, 2014, 4:47am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083 "2014-10-24T04:47:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![starfighterdude](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/starfighterdude/32/464988_2.png) [@starfighterdude](https://forums.unrealengine.com/u/starfighterdude)\
**Post date:** [October 24, 2014, 4:47am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/1 "2014-10-24T04:47:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [October 24, 2014, 5:59am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/2 "2014-10-24T05:59:58Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![karlozm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@karlozm](https://forums.unrealengine.com/u/karlozm)\
**Post date:** [December 17, 2014, 10:55pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/3 "2014-12-17T22:55:31Z")

</div>

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:

```
GetWorld()->GetMapName()

```

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

```
GetWorld()->StreamingLevelsPrefix

```

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [February 21, 2015, 6:35pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/4 "2015-02-21T18:35:04Z")

</div>

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();
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [March 26, 2015, 6:22pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/5 "2015-03-26T18:22:46Z")

</div>

Hey, what do I put as the source actor?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [March 26, 2015, 6:27pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/6 "2015-03-26T18:27:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![karlozm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@karlozm](https://forums.unrealengine.com/u/karlozm)\
**Post date:** [March 26, 2015, 6:32pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/7 "2015-03-26T18:32:36Z")

</div>

CBFlood,

“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:

```
 GEngine->GetWorldFromContextObject(WorldContextObject)->GetMapName();

```

That’s it!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [March 26, 2015, 7:58pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/8 "2015-03-26T19:58:41Z")

</div>

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

Tiles levels have multiple ‘maps’

---

<div class="post-metadata">

**Author:** ![I-BGS-I](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@I-BGS-I](https://forums.unrealengine.com/u/I-BGS-I)\
**Post date:** [April 15, 2015, 1:41am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/9 "2015-04-15T01:41:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [April 23, 2015, 5:34pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/10 "2015-04-23T17:34:48Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [April 23, 2015, 7:26pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/11 "2015-04-23T19:26:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [April 23, 2015, 7:26pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/12 "2015-04-23T19:26:34Z")

</div>

Thanks for figuring that out.

---

<div class="post-metadata">

**Author:** ![I-BGS-I](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@I-BGS-I](https://forums.unrealengine.com/u/I-BGS-I)\
**Post date:** [April 23, 2015, 7:58pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/13 "2015-04-23T19:58:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_01dd28a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_01dd28a6](https://forums.unrealengine.com/u/anonymous_user_01dd28a6)\
**Post date:** [April 23, 2015, 8:29pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/14 "2015-04-23T20:29:53Z")

</div>

They get loaded automatically by Unreal as the player travels.

---

<div class="post-metadata">

**Author:** ![anon53135875](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon53135875](https://forums.unrealengine.com/u/anon53135875)\
**Post date:** [October 19, 2015, 12:07pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/15 "2015-10-19T12:07:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shiwron](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@shiwron](https://forums.unrealengine.com/u/shiwron)\
**Post date:** [September 1, 2016, 7:54am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/16 "2016-09-01T07:54:25Z")

</div>

Hello!  
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.

---

<div class="post-metadata">

**Author:** ![MJBrune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MJBrune](https://forums.unrealengine.com/u/MJBrune)\
**Post date:** [July 10, 2017, 10:04am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/17 "2017-07-10T10:04:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DrHobo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrHobo](https://forums.unrealengine.com/u/DrHobo)\
**Post date:** [December 1, 2017, 4:12am UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/18 "2017-12-01T04:12:42Z")

</div>

Love it. Here’s the shorthand:

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

---

<div class="post-metadata">

**Author:** ![Zarum5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zarum5](https://forums.unrealengine.com/u/Zarum5)\
**Post date:** [July 30, 2023, 4:00pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/19 "2023-07-30T16:00:52Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/f/c2fb7a9e9fd859ac9a4b8bd85d81abd151749003.png)  
It’s a little hacky, but I just did this. All in bp. 😃

---

<div class="post-metadata">

**Author:** ![anon53487532](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon53487532](https://forums.unrealengine.com/u/anon53487532)\
**Post date:** [January 9, 2024, 4:14pm UTC](https://forums.unrealengine.com/t/how-to-get-level-name-in-bp/297083/21 "2024-01-09T16:14:58Z")

</div>

Thanks dude you are life saver.
