5
\$\begingroup\$

Could anyone clarify a beginner's question in Godot?

As in this 3D video tutorial (https://www.youtube.com/watch?v=-D-IcbsdT04), the guy creates one scene for the floor, another scene for the wall, and so on.

But from the concept I have of "scene," everything that appears at the same time should be part of just ONE scene.

Why this technique of creating multiple scenes for objects that will all appear together in one (and real) scene?

\$\endgroup\$
10
\$\begingroup\$

The term "scene" in the context of Godot is kind of a misnomer. What a "scene" actually is in Godot is a reusable object template you can instantiate multiple times. You can edit the instances to give custom properties to each of them or you can edit the scene itself to change the properties of all these objects together.

If you are coming from Unity, then you might find that they are conceptually very similar to what Unity calls "prefabs".

Those reusable objects can be nested in each other by adding a node to an existing scene which is also a scene. Many games use nested scenes a lot. Let's say you have a 3d adventure game where the player explores buildings in a 3d landscape. Among many other game features, the player can find books in these buildings and read them.

  • You will have one game root scene with multiple "building" scenes as sub-nodes.
  • Each "building" scene has multiple "room" scenes as sub-nodes.
  • In those "room" scenes you have multiple "bookshelf" scenes as sub-nodes.
  • In those "bookshelfs" scenes you have multiple "book" scenes as sub-nodes.

Change the material in the original "book" scene, and all the books in all the bookshelfs in all the rooms of all the buildings will be affected. Except, of course, for those where you are overriding the default material. Which you can do on any of these hierarchy levels.

For more information about scenes, see the Godot manual about scenes and nodes, about scene instancing and about nested scenes.


I still don't know why they call those "Scenes", though. I would guess that the thought process during development had to be something like this:

Developers: I hereby present you the basic concept of the "Scene". It's a container for everything there is in your game right now.

Users: You know what would be cool? If we could have more than one scene in our project. So the title screen and the character select screen and the game itself and the scoreboard can all be developed independently. What do you think?

Developers: Great idea! Implemented!

Users: You know what would be even cooler? If we could have more than one active scene at once in the game! That way I can show my scoreboard with my game in the background.

Developers: Hmmm... How does that fit into my architecture of everything being nodes in one big tree? I got it: Scenes can now be nodes in other scenes! Implemented!

Users: We just discovered something cool! You can abuse this system to create kind of mini-scenes which just include a single object in your game. We can put those into the main scene over and over again to duplicate objects. And then when we edit that mini-scene all the objects in the game change at the same time. Neat!

Developers: You crazy fools! Scenes where never supposed to be used that way! This is madness... wait, actually this is a pretty clever way to use that feature. Keep doing that!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.