Labels

Thursday, February 5, 2015

How to Create a Global Audio Volume Control (Sound Slider) Using UMG - Part 2


Hey guys, so for part 2 of our sound tutorial we are going to be setting up the sliders on the menu, and setting up the blueprint for the sound menu.


Created for UE4 v4.6.1, Rama's VictoryPlugin Required


So the menu in this example is a little sloppy looking, but for our purposes it gets the job done.  First we want to create the menu elements.  To get the basics on adding menu elements, such as the text and buttons, we have a tutorial for that here.

To get our slider, once you have the framework for your menu setup, go in the Common section of your Palette and find the Slider object.  Then select the container you wish to put it in, in this case [Vertical Box].  Then drag the slider onto the menu layout.


Once we have our sliders in place, select one of them and the properties to that slider should appear in the details tab on the right. Scroll down until you see the Events tab, and expand it.  There should be 3 options available: OnMouseCaptureBegin, OnMouseCaptureEnd, and OnValueChanged.



Click the "View OnValueChanged" button, and this will bring us to our Event Graph with a handy OnValueChanged event already added for us. 

Now you will want to install Rama's VictoryPlugin pack.  We have a tutorial for installing plugins here, or Rama has a unique install guide for this particular plugin here.  Once you have the plugin installed, we are ready to move on to the next step.

In the event graph, right click and type in "Victory Sound Volume Change" and add that function to the graph.  Connect the value output pin on the OnValueChanged event and connect it to the New Volume pin on the Victory Sound Volume Change.  Then set the Sound Class Object to SFX.  When done, it should look something like this:



The above graph will change all sounds associated with SFX based on the slider value.

Now we want to create a function that gets the Slider Value.  This will allow us to set the slider's initial value when the settings menu is opened, instead of the slider value defaulting to zero or some other value.

In the Appearance tab under Details on the right, there is a line labeled "Value." This allows us to set an initial value for the SFX slider, and it also allows us to bind it to a function, so select "create binding" to set up the function.  We will call it Get SFXSlider Value for this example.



Right click on the graph, and type in "victory get sound volume" and add that function to the graph. Set the Sound Class Object to SFX (the child class we set up earlier to handle all sound effects). Then connect the Return Value output of the function to the Return Value pin on the ReturnNode. When you are done, you should get something like this:



So now we have a slider that will adjust the volume of every sound element that is in the Sound Class SFX.

1 comment:

  1. Thank you, was very helpfyl, 1 question, how do I make this global, where when I go to another level, it does not reset the volume?

    ReplyDelete