Hello, I want for the option menu after pressing the back button if the level is open take me back to the pause menu, if not take me back to the main menu

So I made a boolean variable which tells if the level is opened or not.

After that if the option button from the pause menu is pressed is opening the option menu, and here comes the actual problem is: if the back button when the level is open to get the player back to the pause menu, if the level is not opened to get the player back to the main menu, the code looks like this:

How can i get “OPEN LEVEL variable” from the level selecter menu?

Thanks to all!

Use a reference to the menu widget, instead of a bool:

Input action pause is just the escape key ( can also be the back arrow for you ). See I can tell depending on which menu is in the variable, whether I need to reload the main menu, or exit the menu system…

I’m sorry, but i can’t fully understand what have you done there, can u please explain more your code

Thanks!

Sure thing.

Have a variable which is a reference to the menu you want to load.

When the player first presses ESC, this variable will be empty, then you know to load the main menu ( set the reference to the main menu also ).

If you’re in the main menu and they press ESC, you can tell from the variable the menu is loaded. Unload the menu and clear the variable.

When you go to a sub menu, you set the reference to the submenu. That way, when they press escape again ( or back arrow ), because the variable isn’t the main menu, you know to unload the sub menu, and re-load the main menu.

Does it make sense?..

You can of course do it with bools, but then you need to have bools AND menus flying around… :slight_smile:

( Tell me what you want and I will either do a clearer example like this, or with bools :slight_smile: )