Menu widget fires music multiple times

Hi,

I have a Main_Menu widget that starts music, when I click the Options menu and hit Return the music starts again, duplicating the music track, this is because of the ‘Event On Initialized’ event, but how do I make it so that the music only plays once when returning to the Main Menu?

Start Music at Main Menu then access the Options sub-menu (secondary widget)

Return to Main Menu from Options menu (main widget)

But you do not return to Main Menu. You create another Main Menu. Now you have 2 main menus. For a while at least; since the Main Menu is not referenced (never was? - we can’t see how it’s created for the first time), it will be scooped up by the Garbage Collection in a little while.


Perhaps look into how a Widget Switcher works. Think of it as of a book where each widget is a page and the book can only show one page at a time. You can switch between the pages without having to remove / create them. And since all pages exist, you can still control with them, even though they’re not showing atm.

I hate to be a pain, but do you think you could guide me on how to configure that?

  • consider this setup:

image

All the menus live in the myWidget’s switcher:

image

  • you can switch between them directly or using an Index:

No need to create / remove anything apart from the myWidget that holds it together.


  • let’s say we want to return to the Main Menu from Controls; add a basic dispatcher to the wControls and have a button call it:

  • Now we can return the menu we need:


The above can be set up better but should work just fine for a menu with a dozen or so screens. It, of course, assumes we’re displaying one menu at a time rather than some multilayered overlapping fancy 3d carousel stuff.

Hi,

Thanks for responding, I have created the widgets, made them variables in the ‘myWidget’ and added them into the graph as variables but I can’t see an option for ‘Set Active Widget’ or the ‘Widget Switcher 32’ variable or a ‘Set Active Widget Index’

You need the switcher, ofc:

image

I have created the widgets, made them variables in the ‘myWidget’ and added them into the graph as variables

I hope you have widgets as seen in the hierarchy above. Creating just variables is not enough. To clarify, we’re not using this button at all:

image

Okay I believe I have it right now, so how do I call the music correctly

Create a custom event in the widget that plays music and call that event. if the main menu was playing music:

Something else can call it:

image

The music still isn’t starting

It’s a custom event. You need to call it somehow. See previous post.

Where did you get SET / New Var from?

Same as you…

Something still isn’t right, the music isn’t playing

  • :white_check_mark: how are you adding the widget to the viewport?
  • what’s the value of Menu Music?
  • the Return Value is not connected, the reference is invalid

Ah, it was because I was calling the old widget instead of the new one that acts as the widget swither

1 Like

Thanks for your help on fixing this, really appreciate your lightning fast responses too! :slight_smile:

1 Like

Sorry I spoke too soon, it still duplicates when I return from Options
Return value is connected

Don’t hook it to initialise then. Have a custom event and call it when needed.

The thing is that I see what there is duplicate? This should never ever fire more than once since this widget just sits and does nothing else but controls other bits.

Do you re-add this whole thing to the viewport?

Doesn’t start all when I use a custom event

Because Custom Event needs calling. They give you a chance to start / stop when you need it. I am a bit confused by what is needed, see above.