Toggle Music On/Off From UI Widget

watch the execution wires light up when you press the button though.

You’ll see that the execution flow goes through the boolean, sets it, then… Adds audio component.

So the boolean is getting changed. Watch the value and you will see that with your own eyes.

But, what is not happening is that you aren’t doing anything with the boolean yet! Lol.

So you need to put it to use.

The way to do that is make a Branch node after setting the boolean. The branch node will act like how you had the flip flop. The boolean goes into the branch as the input, and from the True you can set the audio component, and from false you disable it.

This will act the same way as you had before, except that it will always work, even if you destroy the widget or call the function from somewhere else.

1 Like