0 votes

I'm trying to make my sound settings stay there when I change scenes but nothing I try works. Here is the script for the sound settings:

func _on_MasterSlider_value_changed(value):
    AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"),value)


func _on_MusicSlider_value_changed(value):
    AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Music"),value)


func _on_SfxSlider_value_changed(value):
    AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Sound"),value)
Godot version 3.3.3
in Engine by (298 points)

What is the goal here? What exactly changes, and what stays the same?

So when the hslider is moved, the value the hslider has been changed to also makes the decibel level on the selected audio bus change. For instance, when you move the sfxslider from right to left it mutes the sfx because it is -24db. I want to find a way for the change on the hslider to affect a singleton script so that the setting stays the same in every scene.

Have you tried something like the following?

func _on_MasterSlider_value_changed(value):
    settings_singleton.set_master_bus_volume_value(value)
    AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"),value)

If the audio settings aren't applied in other scenes, have them set on load:

# In the scene that requires changing the audio.
func _ready():
    AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), settings_singleton.get_master_bus_volume_value())

Please log in or register to answer this question.

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.
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 webmaster@godotengine.org with your username.