How do I call current streamed level in blueprints?

Basically I want to randomly load a level, then unload it to randomly load another level. To unload it I need to call the name of the current streamed level.

All I can find is ‘Get Current Level Name’ but I have a feeling that will call my main persistent level, which is what I use for lighting and other things. I only want it to call whatever level was randomly streamed in.

Is it possible, when the level is loaded in, to automatically create a variable of its name in that new level’s blueprints that can then be referenced?

Problem with that is I then need to bring that information back to my main persistent level…

Hey again, one thing that you need to take into account is that only sections visited for the first time should be picked random, you might need to keep track of the level types you’ve spawned along the way so you can backtrack the same way, unless that is not a concern for you. To know what is the current level you are in you can try the Get Current Level Name as you said, if that doesnt work you need to use triggers to set that automatically.

Oh yeah…■■■■. I need it to remember what the last level spawned was so I can ‘go back to it’. Otherwise it’s just gonna do a random level every time.

I did get the random level thing working, but now I gotta go a few steps further. Haha.

Like I said, Get Current Level Name is going to reference the persistent level, not the new one that’s being streamed in right?

In this case I want to reference L_GG_1, without having to type the name in as it’ll be random which level spawns.

224603-screenshot-3.png

Yeah Get Current Level Name will give you the persistent map name, maybe use triggers to set that. See if this works.

Yeah I saw that post. It’s a bit embarrassing but I don’t know how to program. I need a solution that uses blueprints.

The biggest question here is that i don’t know if there is a way to get the containing level in blueprints, which you can do in c++ with:

Actor->GetLevel()->GetOuter()->GetName();

With that information the trigger will know in what level he is in, and as soon as the character walks through it, you just set a variable telling that that is the current level.

I figured it out. Pretty simple really.

I just created a variable which randomly loads a streamed level based off of a list, then puts whatever level that’s loaded in to a variable, then uses that as the ‘current streamed level name’.

I also had each teleport create a variable between 0 and 3 to then be referenced later on if I want to teleport the player somewhere else on the map depending on which side of the map they left.

No one copy this though as this doesn’t actually work yet, still figuring out the order to do things. As this setup just unloads the level that was just loaded. I need to figure out how to get it to unload the level only once you’ve teleported and loaded a new level.

i was assuming that you wanted a smooth transition and free control of the character, using teleport will pop you, but if that works for you that’s great. Anyway, at least on your screenshoot you are not plugging the set level name to the execution wire.

I figured that out shortly after I posted it, yeah. Thanks. :slight_smile:

THE SOLUTION!!!

Finally got this working.
Okay, I set the levels to a name list array variable, then had that output set to a separate name variable which could be called at any time. In this case it’s being called to unload the last level loaded, before a new variable is set.

You can get the streaming level name in blueprints fairly easily.

Do a MultiLineTraceByChannel from the ActorLocation of the player.

Do a ForLoopWithBreak to loop through the hit array. Break the ArrayElement HitResult and cast the HitActor to LandscapeStreamingProxy - when you find a LandscapeStreamingProxy break from the loop.

On the LandscapeStreamingProxy call GetPathName - this returns the complete path to the LandscapeStreamingProxy.

If you examine the path in debug you can see how to Parse the string into an Array with ParseIntoArray. Have CullEmptyStrings ticked.

Selecting the right array element and successive calls to ParseIntoArray will allow you to whittle down the string until you get the actual Streaming Level Name.

A complete solution can be found here:
http://www.ostinelli.net/ue4-get-actor-streaming-sub-level-name/

It requires C++, but it exposes a BP node.