How to Call Blueprint After Exiting Level

My main menu is its own level and when the actual game level ends, I want the main menu to open up again. Now, the level opens, but the game level doesn’t seem to completely close as the sound effects still play even though I opened up the menu level. On top of this, the main menu’s music does not play at all.

This is the code I use to establish a win condition and the subsequent behaviors following a victory:

This is the blueprint that I use in the main menu level to control and start/stop the music based on which sub-menu is opened, but when I reopen the main menu level, it is not called for some reason. I am not sure the code here is relevant though, as the problem seems to be with calling a blueprint in general, but here it is:

I specifically want the game level to end, and the menu level to be reopened as normal once it does, music and everything.

1 Like

The open level call will trash everything, including menus. You need to open your menu from inside the menu level ( also do the set input mode there ).

I do that and the music blueprint still doesn’t load. And trying to call the music blueprint from the timer blueprint doesn’t work.

I get this error when the Main Menu level reloads:

Now from what I just saw from checking the editor outline, the blueprint does in fact get destroyed and does not spawn in when the main menu is loaded again, and it just clicked that I was doing everything from within the main menu widget, rather than the main menu level blueprint. But I am not sure how to call the menumanager blueprint from the level blueprint, as I was using a widget call the whole time.

What I need to do is create the blueprint every time the level loads.

1 Like

You need the menu manager blueprint in the menu level, then you can call it from the level BP?

Just make sure everything you need to do the menu stuff is in one level.

I just physically added the blueprint to the level so it will be there whenever I load the level, but despite calling the instance from the game level the music still doesn’t play.

I get the same runtime error even though I get no errors in the graph because using these nodes in the game level still does not access the menumanager blueprint. I think I am just not properly calling the blueprint in the level event graph, but I thought using the game instance node to do that would work, which it isn’t here.

1 Like

This is happening because this reference is no longer valid. It’s pointing to something that doesn’t exist anymore (wiped when you changed level). This is what access none means.

You need to get a fresh reference to blueprint in question when you change the level. It will spawn in it’s default state. Try using get actor of class and save it in your instance, then see if it will work.

What you could also do, is save all relevant information in a struct inside your game instance before you change the level, then change the level, spawn new actor (YourManaagerClass) and set what you need to set. Also doing it on Begin Play in level blueprint might not be the best thing to do, since you can never guarantee when will this Event Fire off. Most likely it will fire before your get your reference working, so the error will still be there.
Have you tried adding some delay, could be a fraction of a second that you need. Try experimenting with that.

You will not get compile error because “technically” there is nothing wrong with it, apart from your reference not being valid (at the time of call).

Did you set your game instance in the project settings?

So I managed to get the music playing by using Get All Actors of Class and attach a function from my game instance to it, but the problem is that I need to reference the whole menumanager blueprint because I have multiple songs for different submenus that have to be switched between. Here is what I did, which is still in the level blueprint for now as I just want to make sure it works somewhere before trying to implement it elsewhere more complicated with code:

Yes, and works fine when loading up the level the first time. The issue is just calling the blueprint it’s connected to, or maybe the game instance itself?