0 votes

I am trying to make a menu in my game from which users can change the volumes of all sounds in the game at once. Most games have a feature like this.

I am working in Godot 3.0.

Currently, I have a Sound singleton which consists of AudioStreamPlayer2Ds, one per sound effect. Many of my nodes use this singleton to play their sound effects.

I also have some special nodes which have their own Sound nodes built in. These special sound nodes also consist of AudioStreamPlayer2Ds.

My question is: How can I write a function to change all the volumes of my AudioStreamPlayer2Ds at once?

Should I simply iterate over game objects looking for the nodes and increase their volume_db? Is there a better way?

I searched around for an answer but there's a lot of noise from Godot 2.0, which treats audio differently from Godot 3.0.

asked Apr 3, 2018 in Engine by Diet Estus (1,494 points)
edited Apr 3, 2018 by Diet Estus

1 Answer

+2 votes
Best answer

Have a look at the master bus which is the global object which all sounds are ultimately played through. It has a volume property - in terms of decibels - which you can use to adjust the volume across all channels.

In my game I use that to turn on/off all sounds when I need to.

Just noticed that you asked this in February, so you probably already know the answer I gave above...The original answer given to your question then works perfectly..... https://godotengine.org/qa/24377/change-global-volume-in-3-0

answered Apr 3, 2018 by SleepyTom (134 points)
selected Apr 3, 2018 by Diet Estus

That question was actually posted by someone else. Guess that makes my question a duplicate. Thanks for the help anyway! It's spot on.

Yep just change the dB of the bus that you're using. Can put sfx, bgm into their own buses to control them that way also.

Sorry my bad :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.