I was wondering if someone could help me out, it’s something that I should be able to figure out but I’m honestly stuck at this point.
I made a login screen, and am using a check box to play background music on a loop.
How do I set up the checkbox to play music when checked, or play no spund when not? Should I use Play 2D sound?
When you select the check box you placed in designer view there is a section at the bottom of the details panel called events. It allows you to add OnStateChange Event right onto your graph. From there you can add a branch and put in your functionality for the two choices. Play 2D sound is the correct choice for UI sounds.
This works, but only if they uncheck the box then check it again. I’d like for it to be where, it checks to see if it’s already checked then loops if so. Afterwards it cuts off if they uncheck the box.
How would I go about setting up saved settings as well?
Still working on the sulotion to this, the sound keeps playing even when unchecked. Then if you recheck it, it plays more music while the other one is still playing.
Thank you, I’ll try this and see if I can get it to work. Honestly if I can’t rig something to work the best way, I’ll just try to code it l. Could you post what the blueprint looks like how you set it up please? It’ll help not only me, but others who are looking for help on this subject.
I found the best way to control a looping sound from a menu widget to start play and stop on an audio component added that is added to the blueprint that is adding the widget to the viewport. You can use the widget to play and stop your music by casting to the component. Otherwise you have the problem that you ran into. I made an example of your situation for myself and found it is best to create a variable such as isplaying that is toggled by check box. This variable should be checked by a function on the tick event that would then control when the component is played. To save any settings create a game instance class and add duplicates of your widget’s variables to it. The defaults need to be the same as they were in the widget. When the widget is constructed you should set the widget values from your game instance, and when you destroy the widget you should set your game instance values to match any changes made to the widget while in use.
Hello,
Sorry for the late reply…very busy developing some assets and my original solution would not have been the best for you. Below I have attached the screenshots of a simple setup that accomplishes what you want. It simply creates a sound component and uses its volume multiplier to turn it off and on when the check box is clicked. Just start the multiplier at which ever state you wish to be default. In my example it is set to start the music by default( i.e. check box is checked). Other solutions can cause some interesting errors due to how UMG works…lol. Hope it helps.
Hey thank you so much! This worked like a charm, you’ve helped me out a lot. Cudos to you friend.
One other thing, what was the playmusic function you have set up?