0 votes

i want to know how to control the music and the sounds volum

in Engine by (71 points)

1 Answer

+1 vote

First of all, have a look at the documentation, it explains how audio works in Godot: http://docs.godotengine.org/en/3.1/tutorials/audio/index.html

Then, in code you can either modify individual AudioStreamPlayers: https://docs.godotengine.org/en/3.1/classes/class_audiostreamplayer.html

Or use the AudioServer API to change global volumes: https://docs.godotengine.org/en/3.1/classes/class_audioserver.html

Using the latter, for example, if you have two buses, one for "Music" and one for "Sounds", you can change their volume like this:

var music_bus = AudioServer.get_bus_index("Music")
var sounds_bus = AudioServer.get_bus_index("Sounds")

AudioServer.set_bus_volume_db(music_bus, -10.0)
AudioServer.set_bus_volume_db(sounds_bus, -3.0)

Note: by default Godot only has a "Master" bus (the main one), but you can create new ones specifically for music, sounds and other things.

by (29,118 points)
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.