Using one scene for many game levels

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ogeeice

I have a scene I want to use throughout the game without leaving the scene I also want to include levels like a side quest can this be done or do I have to instanced the scene to all the levels or is there some other easy way

:bust_in_silhouette: Reply From: johnygames

The best way would be to have a main scene (Let’s name it “World”) and have every level as a child to that scene. That way you can have every level instanced once with the ability to cycle back and forth among them. Your scene can be a child of “World” too.
Depending on what you want to do, you could also make a level prototype which contains the scene in question and make any necessary changes to that level, in order to create all the other levels.
Finally, you could create what is called a singleton. This is a global script, whose variables and content are accessible from all over your game. This script is autoloaded in the beginning and you can use it to instance your scene without having to declare it anew everytime. Watch the second half of this video for a detailed description of how to use it:

You can also have a look at the docs: Singletons (AutoLoad) — Godot Engine (3.1) documentation in English

Does this answer your question? What exactly do you want to do?

Thanks for the help

Ogeeice | 2019-08-05 14:29