0 votes

Hey hi guys I am making a game in which I want to reload maingame scene after player presses play in menu here I can’t use reloadcurrentscene cause all my game components are child of a node called by the name world and I kept them all (maingame,mainmenu,shop etc.) for some reason and when I reloadcurrentscene it reloads full game namely world.
Can anyone please help me and tell me what can I do to reload my game scene every time I press play in main
menu.

Godot version v3.4.4
in Engine by (29 points)

1 Answer

0 votes

You may want to use AutoLoad https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html
And move your persistent data/functionality there.

by (14 points)
edited by

Bro there is nothing like auto load in Godot expect singleton and we can’t use them them for reloading a scene

It's literally in the first paragraph of the link I provided:

Singletons (AutoLoad):
Godot's scene system, while powerful and flexible, has a drawback: there is no method for storing information (e.g. a player's score or inventory) that is needed by more than one scene.
...
Using Singletons, you can create objects that:

  • Are always loaded, no matter which scene is currently running.
  • Can store global variables such as player information.
  • Can handle switching scenes and between-scene transitions.

You don't use singleton to reload a scene, you use it to store persistent data.
OP already knows how to reload a scene, and was asking how would he reload his game while maintaining some portion of his nodes/data between those reloads.

Cheers.

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.