level streaming bug. How to solve?

ill start by explaining what i was trying to do when i encountered the bug:
in my game, levels transitions are handled by loading and unloading level instances, mainly with the “Load level instance by name” node. and in order for level transitions to work, the game expects that at the start, the level thats opened is the “Persistent Level”, all actual content is streamed in with the load level instance node. so when i try to use PIE normally, the game breaks, since it tries to start on the level that im editing, which of course is normally not the empty “PersistentLevel” and so im trying to make it so that on the GameInstance event init, the game automatically loads the persistent level (using open level by name node), and then streams in whatever level i had open or just the default level with the load level instance by name node.

as it turns out, whenever i use “Open level by name” any subsequent attempts to use “Load level instance by name” fail, if i bind events to “OnLevelLoaded” and “OnLevelShown”, “OnLevelLoaded” will fire but “OnLevelShown” wont, sometimes it will but even when it does fire the level doesnt actually become visible.

if i dont have the “Open Level By Name” node it works as expected.

trying to add delays before or after “Open level by name doesnt solve anything”.

How to replicate:

  • Create a new empty project in unreal engine 5.5.
  • Create a new empty level, call it “Persistent” or whatever else.
  • Create a new level with something in it so you can tell when it loads, for example lighting, call it “LevelToLoad”.
  • Create a new game instance subclass and set it to the game instance the project uses in the project settings.
  • inside the game instance, create the “Event Init” event, and add the following code:
  • in the editor, open the “LevelToLoad” level, then start PIE, the screen will go black as the “Persistent” level is loaded, and it will stay that way because the level that “Load Level Instance By Name” creates will never become visible.
  • now skip the “Open Level By Name” node and open the persistent level in the editor, then start PIE: the “Load level instance by name” node will work as expected, and the “LevelToLoad” level will appear normally.
  • you can try adding delays to any part of the execution after “EventInit” and that will solve nothing, the only thing that will change is if the event bound to “On Level Shown” fires or not, but the level wont actually appear.

a way to force PIE to use the default startup map instead of the currently open map in the editor would also solve my problem.

1 Like

I have this exact setup ( your setup before modifying the GI ).

I just tried your ‘open level’ approach, and indeed, the streaming is flaky.

I’m wondering, is you game mode the same in all levels? ( mine is ).

Tip ( if you haven’t done this ). All my level instances have no lighting, which is a pain during editing. In fact, you can include the persistent as a sublevel to each level, so you can see what you’re doing. It doesn’t get loaded by ‘load level instance’.

I know that’s a bit off-topic, but I found it handy for this setup.


Update: Very weird, I tried it again, and now I can’t make it go wrong. It seems good enough for testing, although I wouldn’t use it in a release…

1 Like

Another update: I tried this a bit more extensively, it’s pretty good because you can get the GI to always load the level you’re working on, with a bit of fiddling

and then in the persistent

The only level instance that failed for me before was a lift. I managed to get this to happen again, and discovered the lift was actually elsewhere. Is this possibly happening with your instances? ( really depends on how things work with you ).


Another update ( I give up :slight_smile: ): I can get this to regularly not load a level instance, there is a pattern. If I’m editing level X, which contains code to load level Y, and press play, level Y will not load. I think what is causing this is

1 Level X has code to automatically load level Y
2 PIE loads X ( because I was editing it ), which starts to load Y
3 Open level opens the persistent
4 Persistent reads that I want to stream X and starts re-loading it
5 X now, again, attempts to load Y, but Y is already marked for unload since the ‘open level’
6 We end up with no level Y


Indeed, delaying the stream of level Y, did the trick…

1 Like

it seems that the way ive set it up in my game is completely different from yours, i dont have any logic inside a specifc level to load another level, and i use this for full level transitions, the levels i load do have their own light.

the way i have set it up, i have a level called “PersistentLevel” which is the one that should always be loaded at first because it is completely empty, then the actual first level with content is streamed in with “Load Level Instance By Name” and any time theres a level transition, its handled by a manager that lives in the persistent level, first it unloads the current level completely, and only once the current level has been unloaded it starts loading the next one.

im not sure how this is all relevant, just trying to clarify that my setup is pretty clearly different to yours.

i did try to do the “Get Current Level Name”, store it in a variable, then load the persistent level and then use “Load Level Instance by name” with that variable, but the result was the same, the level never becomes visible, which is very obvious because my levels do have lighting, and even if it was just a lighting fail, i have also inspected them in “Unlit” and “Wireframe” views and nothing shows up even then

i have tried to add delays to every part of the sequence, very long ones too, but nothing fixes it, once there has been a call to “Open Level By Name” any call to “Load level instance by name” returns a LevelStreamingDynamic object that never becomes visible.

1 Like

Ok, it’s very different :slight_smile:

I’m pretty sure the node ‘load level instance’ was some exposed code from @Rama. It’s a sort of ‘short cut’ node that uses streaming to load a level, without the need to have all the levels you want to stream as sublevels of the persistent.

You might try tinkering with the traditional level streaming, it might be different enough to work for you?..