Change audio volume (Audio slider)
Hey, I want to implement simple audio sliders that control the volume of various sound classes (Master, Music, SFX). I set up sound classes and their hierarchy, but now I need to access the volume multiplier somehow, which does not seem to be possible.
I've searched for quite a while but couldn't find an answer. It seems that either no one had this issue before, or I'm just mussing something obvious here. I hope you can help me with this.
asked Mar 20 '15 at 09:54 PM in Using UE4
Hi. Not sure if this is what you meant, but this is what I did for a project I'm currently working on. (I just made a new empty project to test it for explanation purposes)
First I made a Widget Blueprint and just put a slider in it. Then I created a "binding" on the Value of the slider.
Then in the binding (I named it "Get Music Volume) just make a new float variable (called mine Music Volume) and connect it to the return value. Put the default value on the variable to 1.
Then go back to the slider and make a "OnValueChanged Event" from it. Set the Music Volume variable based on the Value from the slider event. So that the Music Volume variable will be changed based on the sliders position.
And lastly set it all up in the level blueprint (or wherever best suited depending on your own project). At the start of the event I created the slider widget and made a reference to it that is again used for the "Cast To Slider" which gets the Music Volume variable from the Slider Widget.
Put the sound you want to play out in the level and reference it in the Level Blueprint. make a "Set Volume Multiplier" and drag the Target node to the music reference and it will create the "Audio Component" thing between them. Connect the Set Volume Multiplier with the Music Volume variable, and it should work. (just have a camera in the level and get the mouse to show up so you can drag the slider)
When you start the level now, the music will start and you can turn the volume up or down with the slider.
I used this to change the Music Volume in my project, just connect every in-game Music or Sound effects up to a slider like this and maybe have it in a pause menu or start menu.
Hope this helps :)
answered Apr 26 '15 at 03:23 AM
Couldn't find any blueprint-only solution, so I've maked it in code. There is C++ example.
answered May 11 '16 at 10:13 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here