This is where things start getting abstract, but don’t panic. There’s not much more depth than this.

In previous tutorials, everything revolved around the concept of nodes. Scenes are simply a collection of nodes. They become active once they enter the scene tree.

This concept deserves going into a little more detail. In fact, the scene system is not even a core component of Godot as it is possible to skip it and write a script (or C++ code) that talks directly to the servers, but making a game that way would be a lot of work.






One of the ways to explain how Godot works is that it’s a high level game engine over a low level middleware.


In any case, the scene system provides its own main loop to OS, SceneTree. This is automatically instanced and set when running a scene, no need to do any extra work.

It’s important to know that this class exists because it has a few important uses:

  • It contains the root Viewport, to which a scene is added as a child when it’s first opened to become part of the Scene Tree (more on that next)

When a node is part of the Scene Tree, the SceneTree singleton can be obtained by simply calling Node.get_tree().

Root viewport


GetTree().GetRoot(); // Access via scene main loop.
GetNode("/root"); // Access via absolute path.

This node contains the main viewport, anything that is a child of a Viewport is drawn inside of it by default, so it makes sense that the top of all nodes is always a node of this type otherwise nothing would be seen!

While other viewports can be created in the scene (for split-screen effects and such), this one is the only one that is never created by the user. It’s created automatically inside SceneTree.

Scene tree




When nodes enter the Scene Tree, they become active. They get access to everything they need to process, get input, display 2D and 3D, notifications, play sound, groups, etc. When they are removed from the scene tree, they lose access.

Tree order

Most node operations in Godot, such as drawing 2D, processing, or getting notifications are done in tree order. This means that parents and siblings with a smaller rank in the tree order will get notified before the current node.


“Becoming active” by entering the Scene Tree

  2. The root node of that scene (only one root, remember?) is added as either a child of the “root” Viewport (from SceneTree), or to any child or grandchild of it.
  3. Every node of the newly added scene, will receive the “enter_tree” notification ( _enter_tree() callback in GDScript) in top-to-bottom order.
  4. An extra notification, “ready” ( _ready() callback in GDScript) is provided for convenience, when a node and all its children are inside the active scene.
  5. When a scene (or part of it) is removed, they receive the “exit scene” notification ( _exit_tree() callback in GDScript) in bottom-to-top order

Changing current scene


func _my_level_was_completed():
public void _MyLevelWasCompleted()



func _my_level_was_completed():
public void _MyLevelWasCompleted()
    var nextScene = (PackedScene)ResourceLoader.Load("res://levels/level2.tscn");

These are quick and useful ways to switch scenes but have the drawback that the game will stall until the new scene is loaded and running. At some point in your game, it may be desired to create proper loading screens with progress bar, animated indicators or thread (background) loading. This must be done manually using autoloads (see next chapter!) and Background loading.