0 votes

Excuse me, I tried to change script for singleton but it doesn't work. Am I doing it wrong?
I also tried other combination but still wont work until now. Can I even change singleton's script in runtime? If not, can I make singleton in runtime?

I have a singleton that will have 2 different script based on if it's client or server. When the main scene loaded, it will detect if the game is running as client or server then change it's singleton script. Is that bad practice?

in Engine by (18 points)

You can't make so-called singleton at runtime. What you can do is to add a scene as a child of root:

$"/root".add_child( aScene )

It will be accessible where SceneTree is.

ah i see, thank you. hmm, well if I can't do that, I think I'll just make a child of a singleton and then reference it manually to all nodes who need it.

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 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.