master sfx volume control?

Hello,

How can I control all the sound effects volume in the game, with one slider? I have a dozen of blueprint assets that play different sounds when I interact with them, here is how I have them connected to play the sound.

And here is the UMG that has the master slider:

Thank you!

Can someone tell me how to make a master sound control?

Hi,

If you click on that litlle arrow at the bottom of the PlaySound2D node, you will see an input called VolumeMultiplier. Make a MasterVolume variable in your Game Instance class and use that value everywhere where you play a sound (by casting to your Game Instance). Obviously, you want to update the MasterVolume variable from your widget.

I hope this will help you.

Hi ,
This is a great solution, but when I try to migrate the asset that has the playSound2D node, it says (in the asset report dialog) that it will export the game instance (that I’ve explicitly cast to in the blueprint) also. I’d like to be able somehow to create a public game instance variable (in the specific actor blueprint) that I can set on each blueprint actor, when placed in the scene.

Hi,

Now i am a bit confused about what you actually want to achieve. I thought that you have a settings menu where you want to set a master volume and you want each sound in your game to has that master volume when it plays. If so, my previous solution should work. However you mention migrating, what are you exactly mean by this? Are you trying to migrate the Blueprint class to another project? If so, it probably wants to export the Game Instance class as well because you are casting to it. Unfortunately in my understanding, there is no other way to preserve variables over the game than saving it to the Game Instance, therefor you need to cast to it. Game Instance is not a variable type but a class, so you cannot create a Game Instance variable. It is the only class in the engine (without modifying it) that won’t be reset when you load a new level, this is why you need to use it in order to have the same volume level across your game.

I hope this helps.

Yes, I want to be able to migrate the blueprint asset to another project, where the destination project doesn’t have a options menu (I’m trying to make a flexible assets, that are not depended on external blueprints, such as game instance). And yes I was wondering if there was any other method of getting to the game instance without casting to it, so it won’t get migrated over to another project.

Hi,

Okay, now I understand. Another solution is to literally save the variable to the user’s PC using SaveGameToSlot but that solution requires casting as well.

To be honest I don’t think it is possible, because there are no global variables in the engine. And if you are planning to save out those assets without any dependencies, how do you expect the exported asset to figure out what value to use? Where would you store and then later use the selected volume? This is what Game Instance is for.

The way I was thinking is, just like the soundFx variable that I have set up (see the blueprint in my #4 post). Every actor blueprint can have public variables, so I created an variable of type sound base and made it public - so it doesn’t reference to a specific sound cue in my editor. I can then drag the actor blueprint in the scene and set the sound cue variable in the scene reference of that actor blueprint. This way when I try to migrate the blueprint asset, it doesn’t export any sound cues, because the public variable is generic sound base, not a specific sound cue.

I hope this is easy to understand.

Now I have another idea how I could make the master volume without the game instance, but that requires to drag and drop all the sound cues of all the effects in the scene, and do a “for each loop” on them and adjust the volume one by one.

Thank you for your time to help me.