+3 votes

When constructing a game to completion is it better to have everything be a part of one major world scene or instance multiple scenes into a main scene? What are the pros and cons to using one approach versus the other with this engine. Trying to get as many details as possible before I get too far into my 2D project, any additional advice to someone new to this engine who is making a game is welcome. Thank you in advance.

in Engine by (57 points)

Thank you all for your answers. =)
From what I gather here independent items like, player, enemies, collectibles, certain programmable objects for level mechanics can be instanced into a scene thats mostly comprised of the level design and low memory static objects. I can see how preloading loads parts as the player gets to a certain part of the level could make the initial load of the level significantly faster as opposed to everything being inherent to it at start. I'm guessing finding the best balance is really just going to take experimentation, experience and benchmarking my game in different variations when the first level is done. I like breaking and rebuilding stuff, should be fun ;)

3 Answers

+3 votes
Best answer

When I start a game, I already know that stuff like collectibles, enemies, the avatar, the GUI or levels will be scenes, because they are distinguishable objects you can work on independently.

Then, I usually create a "play.tscn" scene to start the game and assemble parts here for the first prototype. Having a unique scene at the beginning is OK to quickly prototype something, but it shouldn't last too long. If I feel some parts need to be instanced or separated from others, I extract them as new scenes.

On the other hand, I don't feel it's good to over-separate things, unless you want them to be modular (ex: level layout + enemies layout). Just separate things you need to be separated.

As for how the game runs, I still don't use auto-load nodes yet. Instead, "play.tscn" is my "host" scene under which I load levels, and I never use change_scene() because all I have to do to load a level is to destroy the last one, and instance the next one. Because, well, scenes are prefabs, and prefabs can be scenes. The only reason I would use auto-load is for nodes that exist for the entire lifetime of the application (including menu, game, everything). Do the way you feel better :)

by (27,603 points)
selected by
+2 votes

You wouldn't want to have your whole game in one scene. Don't think of scenes in Godot like a level or something, more of a self-contained component that you can include when and where you need it (by instancing). This gives you much more flexibility at the expense of more files and navigating around in the editor (if that's a con). Not a very in-depth answer sorry.

by (714 points)
+2 votes

It depends on the game you want to make.
For example if your game is like the old arcades, the best practice is to switch scenes as the game advances. This way you are limiting the usage of cpu, memory and etc
But if your game is something like an open world game then you are almost doomed to load everything up and find tricks to lower the usage of cpu, memory and etc.

My best advice is to create a small game first (like the old arcades ) so you can get used to Godot.

by (171 points)

An open world profits even more from splitting up scenes. Just divide the world into quadrants and instantiate them when the player gets close.

Yes you can use for example the VisibilityNotifier2D for this or do any other trick. But unless you want your game to freeze when ever you load a part of your world you must preload all the world.

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.
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 webmaster@godotengine.org with your username.