0 votes

I'm beginning to use AutoLoad for singletons and am wondering what does the Singleton "Enable" option actually do or enable?

in Engine by (255 points)

1 Answer

+3 votes
Best answer

If you add a singleton script like this:

extends Node

var score

func _ready():
    score = 0

func incrementScore():
    score += 1

You can then add this script as Singleton and name it as ScoreManager. Then in anywhere in your game you can call

ScoreManager.incrementScore()

To increment your score.

You can use this technique to switch between scenes, manage music with crossfade transitions between scenes, manage sfx etc..

by (750 points)
selected by

Very convenient. Nice!

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.