How do I keep a setting between scenes?

Godot Version

4.2.2

Question

How do I have a setting save between scenes?
I have made an FPS counter that you can enable in the settings, but how exactly do I make whatever you choose in the settings affect every scene? I know how to do this with audio busses, but not visual things. I am new to coding and I am confused.

When using change_scene_to_file you will need to store things in an Autoload, or save and load them from a file.

1 Like

I read all of that and did the tutorial example project but I don’t understand how I can implement it for settings to make a sprite hide or not. Even in the example project tutorial it seemed like it did nothing at all because its just a scene switcher but way more complicated.

It’s an hour long, but it sounds like what you want: Saving and loading games with Godot

If you’re really not able to watch the full thing for whatever reason, the part you’re looking for is Handling Dynamic Changes which is at 26:00

In the example it is being used to store data, which is something you’d like to do too. The missing step is using that data.

The FPS counter should itself be an Autoloaded scene that persists through the game, then save and load from a file as a setting.

You can check on _ready to hide or remove a sprite

extends Sprite2D

func _ready() -> void:
    if PlayerVariables.health < 50:
        visible = false
        # or
        queue_free()