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.