OPEN LEVEL is not working

Hey. It’s been a long time and I’m not sure if you have already got your problem sorted out. But I happened to run into this problem today as well. After some searching and trial and error, I figured out the solution as well as the reasoning behind it.

In my case, the problem happened because everything was set up in a way that got trapped in a loop. Let me explain with the help of a diagram.

I have a Level_A, which has a Game Mode_A and Level BP_A associated with it. I wrote the code to generate the UI in Game Mode_A. You might put them in Level BP_A. Regardless, they have the same effect.

Now when I click Play in the Unreal Editor, an instance of Level_A got loaded into the game, which I will call Level_A_1. This Level_A_1 calls both Game Mode_A and Level BP_A and as a result, an instance of UI_A is generated. Let’s call it UI_A_1.

To this point, I see a UI showing up in my screen, which is UI_A_1, but in fact behind the UI, Level_A_1 is already running there. If you have some sound effect in the level you should be able to hear it as a piece of evidence.

I haven’t clicked the Play Button on the UI so far. When I click it, new things happen. The click triggers the loading of another instance of Level_A, which I’ll name it Level_A_2.

When this Level_A_2 is loaded, it again runs Game Mode_A and Level BP_A. Here comes the culprit. Another instance of UI, UI_A_2 is generated by them. After that, Remove from Parent is executed. But pay attention, it just removes UI_A_1 from the viewport because this Remove from Parent command is trigger by the Play Button from UI_A_1.

UI_A_2 is still there, which makes you think nothing happens but it is actually not the same UI instance. Until you click Play Button on it again. Now UI_A_2 got cleared But here comes UI_A_3.

So it is kind of trapped in a loop. To get out of it, you have to put the code that generated the UI in a LevelBP or Gamemode associated with a level different from the level that got loaded when you click the Play Button on your UI.