I’ll try to summarize my problem as short as I can.
I created a settings button on the main page of my game that takes you to a separate scene with two draggable sliders. One for Music Volume and one for Sfx Volume.
The main menu scene and the game scene have two different background music, being played on the same channel number.
So I configured the Music Volume slider to change the volume of both these background musics as they’re on the same channel
It works for the main menu volume but it doesn’t work with the game volume despite both background music being on the same channel.
How do I fix this issue so this Volume slider setting would adjust the volume for both scenes?
I do not want to use global volume setting because I’ve made two separate sliders for background music and Sfx
Channels are a way to refer to a currently playing sound. That’s all there is to them. When you set a setting on a sound on a channel, the settings are applied to that currently played sound, not to the channel. You will have to use global variables and start each sound/music at the volume from that variable.
Can you give me a sample on how to set up a global variable for my audio tracks? Sorry I’m still trying to get the hang of Variables.
I cannot, since I am not on my computer. You can read all about them on the wiki and check out examples in the engine.
No worries! I’ve figured out how to use global variable (But i still need your help. One moment, let me explain the scenario now)
So basically, ive made a global variable with each default volume to be 100
and then, when i placed a music track on an action event, I placed the volume to be based on its global variable volume
Hope everything’s considered correct for now…
And now, these are my sliders. I used the draggable extension thingy
Okay, now here’s where I need your help!
At the moment, the code in the green rectangle only affects the volume of the music that’s currently playing because I dont know how or where to slide in the global variable code…
Gosh I suck at writing programs
How do I properly code this in order for the draggable slider control to change the global variable of the volume instead of just the current audio playing?
I tried: MusicVolume.DraggableSliderControl::Value()*GlobalVariable(MusicVolume)
But unfortunately…the slider would still only work on the music that’s currently playing. It doesn’t change the volume of the music on a different scene despite both having a Global Variable and on the same channel. FML
You’re doing it slightly inverse what you’re looking for.
You should be setting the global variable to the slider control value *100.
Then just use the global variable for all volume levels on your events.
The slider control won’t exist on other scenes (or will reset each scene even if it does exist on the other scenes).
What you’d also likely do is set the slider to the global variable value once (at the start of the scene), so it correctly matches the last set volume.
Could you kindly show a picture of what that would look like please? That would help a lot!