How to create a reference from a menu BP to run on a Player Controller

I am developing an interactive project. In the project there are submenus that are in the player controller’s BP. When I press play they are loaded as long as the player controller is set as default.
But now I want to add a start menu to the game, with the start button, settings, etc. This I know how to do. My question is when it comes to hiding the submenus when the main menu is loaded.To load the main menu I opened an empty level and added the menu to beginPlay, and to load the game I added open level by name to the on button click.
Now how do I hide the submenus in the main menu and only load it when loading the game.
I thought of several ways, but I can’t think of a way to connect the player controller’s BP with the main menu’s BP.




Hey @Twitch_Adelt! Welcome to the forums!

So the node you’re looking for is “Remove From Parent”. This is essentially a “Delete current copy of the widget” node. :slight_smile: If you don’t need it for the main menu, when loading in, check for that widget and if “IsValid?” (use the gray macro one, not the blue function one) then “Remove from parent” and if it is not valid, do nothing and move on. :slight_smile:

Thanks for answering me! I made a little progress in this case, but I still haven’t been able to resolve it. Could you take a look at what’s wrong?

Message LOG: Blueprint Runtime Error: “Accessed None trying to read property BP_MasterMenu”. Node: Remove from Parent Graph: EventGraph Function: Execute Ubergraph Iniciar Blueprint: Iniciar
Server logged in
Play in editor total start time 0.169 seconds.

Close!
Try doing a “Get all Widget of Class” after Begin Play, but in this case…

Why not use “Remove All Widgets” before the “Create Menu Iniciar Widget”? That will clear all widgets before you add your main menu to the scene!

I managed to solve it, but none of these alternatives worked. One thing I noticed is that “remove all widgets” or “remove from parent” or even “get all widgets” weren’t working. Apparently they detected it and did their job, but as the blueprint for this submenu was in the player controller it was loaded again. So I changed the player controller from the empty main menu level and loaded the game’s player controller into the game. That is, I need two player controllers in the game. It wasn’t exactly what I wanted but it worked, I couldn’t hide the submenus using the same player controller. But thanks anyway, I learned some things with your help! Happy New Year to you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.