Best practices question.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By independentCog
:warning: Old Version Published before Godot 3 was released.

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.

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 :wink:

independentCog | 2016-05-29 17:12

:bust_in_silhouette: Reply From: duke_meister

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.

:bust_in_silhouette: Reply From: kakoeimon

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.

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

Warlaan | 2016-05-29 09:45

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.

kakoeimon | 2016-05-29 10:59

:bust_in_silhouette: Reply From: Zylann

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 :slight_smile: