0 votes

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

asked Aug 5 in Projects by Ogeeice (124 points)

1 Answer

+1 vote

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: https://www.youtube.com/watch?v=uNNvq9V9ls8

You can also have a look at the docs: https://docs.godotengine.org/en/3.1/getting_started/step_by_step/singletons_autoload.html#doc-singletons-autoload

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

answered Aug 5 by johnygames (614 points)
edited Aug 5 by johnygames

Thanks for the help

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 How to use this Q&A? before posting your first questions.