Hi all! I'm working on creating a radio UI that can utilize the slider element to play audio depending on what value the slider is on. I was able to make a simple switch on/off happen by creating a float variable and attaching it in to an accccdshshsction script. It can switch audio on but I have to check the "play until end" for it to be a single click on the mouse. Otherwise, I have to hold down on the right click for the audio to play. That is the first issue I'm having trouble with. The second, is that I can switch it off when I move the slider back to it's default position/value. Not sure if I am headed in the right direction with the logic, but any help would be great if someone has any ideas. I'll post images when I'm able to later if needed. Thanks!
Comments
Welcome to the community, @stormdog.
Sorry, you'll have to use the exact phrasing of the option - I'm not clear on what field you're referring to.
Can you share screenshots of the ActionList(s) involved, as well as where/how you're referring to them your Menu?
Are you saying that's happening and you don't want it to, or that you want that to happen but don't know how?
How are you playing audio? With regular Sound components, or the dedicated Music system?
I'll still need to see the Actions involved, but it could be that you're making repeated calls to play the same track. What you'd need to do is separately record another Global Variable (either a PopUp or Integer) to record what track you're playing.
That way, when you check the region that the Float value is within, you can also check if the appropriate track is already playing - and only play anything if not.
Hi @ChrisIceBox. Thanks for reaching out, I'm happy to be here!
So, for this part I was able to make audio work when I change the value on the slider for the radio, but I must continue to hold left mouse down in order for the audio to continue playing. Here is a screen grab of the UI element as well as the ActionList I currently have working for it:
https://www.facebook.com/photo?fbid=10213690998789268&set=pcb.10213690999989298
Sorry, I meant to say that I can't switch it off, as the audio seems to be continuing to play when I hold right click down on the mouse, even in it's starting value.
The sound is coming from "Action type: Sound Play Music" in the ActionList Editor. I am using a .wav file.
I'll give this a shot. Sorry, but can you please tell me what the main difference is between using a PopUp and Integer? Thanks for your patience, I'm still a bit new.
Thank you so much for reaching out and giving your insight on this. I really appreciate your help!
I'm getting an "unavailable content" message on the screenshot. Can you post to Imgur instead?
An Integer can be any whole number, so it's flexible but easy to type in the wrong value if you only ever want to deal with a limited set of possible values.
A PopUp is like a "limited" integer, in that it can only have a fixed number of values. Each value also has a separate label/text to go along with it, so in general it's a lot more user-friendly if you only want to deal with a set number of possible values.
https://imgur.com/a/Q96fvKZ
Oh, thank you for the explanation on PopUp!
Don't loop your ActionList back onto itself - it'll re-run by itself.
You'll also need to set its When running property to Run In Background. Otherwise, it'll interrupt gameplay and take control away from the player.
As you've set your Slider menu to pause the game when it's enabled, you'll also need to make sure your Music tracks are set to also be able to play when the game is paused (this is not the default). This can be set in the Music Storage window.
As you're using steps to limit the number of values the Float can have, you should be able to do without any other Integer/PopUp variable - but you'll likely want to also assign the same ActionList asset ("Radio Dial Change") in the Menu's ActionList when turn on field so that the music begins playing without user input.
I'll post some updates and progress!