Triggering a Menu Anchor

So I’m working on creating the main menu of a 2D platform game. I have a menu anchor on the main menu widget blueprint, and am able to get it to load a World widget blueprint. From the World widget I have it populating the world list in another widget. All that works perfectly OK.

Where I’m having an issue, is that when I select the desired world, I’m trying to get the menu anchor on the main menu to remove the world widget and load the level widget, which will populate all the levels for the selected world.

I’m able to get the world widget to close, but cannot get the level widget to appear. Is there something I’m missing to allow the menu anchor to open up again?

I was able to finally get this to work! What I had to do was the following:

1. Create a new Widget, I called it Menu Anchor

  1. Add a Menu Anchor to the Widget view.
  2. Create a User Widget Variable, I called mine Target Menu.
  3. Create an OnMenuGetContent Function and build it as so.

2. Update the My Character Blueprint

  1. On your Event BeginPlay Add a Create User Widget, and a Menu Anchor Variable

  1. Create a new Function, I called mine SetMenuAnchor
  2. In this section I do several things.
  3. First I check to see if the Menu Anchor widget is already active. If it is I move on to the next step, if not, I add it ot the viewport
  4. Next, using the Anchor Reference, I set what the Target Menu will be.
  5. Finally, I check to see if the Menu Anchor is open, if it is I close it and reopen it. If it isn’t I just open

3. Call your Function.

The last step now is just to call the function. For each Widget you’d like to use it in, you simply set the Event Construct to cast to My Character. Then you simply set the On Button Click (or whatever Event you’d like to use)

Hope this helps someone else, and if anyone has any other ideas I’d love to try them!

1 Like