How to change a sub level variable in level(persistent) blueprint

I am using unreal editor 4.1. I added a sub level via the level windows with streaming method set to always loaded. Then I added a variable in the sub level blueprint. I would like to change this sub level variable in level(persistent) blueprint. I wonder if there is any way to do it, thanks!

I am assuming all Sub-Levels are considered “Streaming Levels” whether they are always loaded or not. Try “Get Streaming Level” using the name of the level minus the .umap, then put the blue output into a Cast to that level, then Set your variable.

Let say I have one sub level called test_road01, and I use “Get Streaming Level” to get the sub level. I have no idea how to cast to that level because there are only for cast options in the popup windows and those options doesn’t seems to be the right one to choose. Can you elaborate more on this. Thanks a lot!

You should see Cast to LevelStreamingAlwaysLoaded, which matches your always loaded level, and you have the Object input which tells it which of your AlwaysLoaded levels to choose from.

I can cast the sub level to object ‘LevelStreamingAlwaysLoaded’ but I don’t know what to do in order to call the function(SetPlay) in sub level “test_road01” in the level(persistent) blueprint.

Do all the cast options have the same result? If Set Play is a function in your sub-level, then it should appear in the context menu when you are dragging off the cast.

There are four cast options(as shown on the screenCap.png):
cast to LevelStreamingAlwaysLoaded
cast to LevelStreamingBounds
cast to LevelStreamingKismet
cast to LevelStreamingPersistent
All the options cast failed excepts the cast to LevelStreamingAlwaysLoaded! SetPlay is the function I wrote and it doesn’t appear in the context menu. I have no idea how to cast the return value of “Get Streaming Level” so that the “Set Play” function appears in the context menu. Thanks you very much!

Hmm, instead of looking for the Set Play function, can you access any individual variables from that sub-level through the cast?

There may be different rules for casting to levels that I don’t know about. Running out of ideas.

Hi, Zeustiak. I cannot access individual variables in that sub-level, but I can select objects in sub-level via the “Select Object” function as shown in the screen cap above, where road_a is an actor in the sub-level. Thanks for your quick reply! :slight_smile:

You could try putting a Blueprint Actor in your sub-level that holds your variable. You then get that Blueprint Actor and pull the variable from it.

Hi, Zeustiak. I did an experiment of your idea as shown below. I created a blueprint actor class called “torusTestBP” and placed a blueprint actor(instance) called torusTmp in the sub level. I tried to cast the return object from Select Object function to TorusTestBP but the cast failed. So I failed to pull the variable from it.

Hi Zeustiak and wing, I even don’t see Cast to LevelStreamingAlwaysLoaded, I only see Cast to LevelStreamingKismet, could you enlighten me? Thanks!