Scenes, Nodes & the Scene Tree
4.1 Nodes
A node is the basic building block. Each node type has a specific job, a name, properties, and can have children.
Base of all nodes; logic only Node2D / Node3D Have a transform (position, rotation, scale) in 2D/3D Sprite2D, AnimatedSprite2D
CharacterBody2D/3D, RigidBody2D/3D, StaticBody2D/3D, Area2D/3D Define the shape of a physics object Control (Button, Label,...) Countdown that emits timeout Keyframe animation of any property Class hierarchy excerpt:
Object
└── Node
├── CanvasItem
│ ├── Node2D ── Sprite2D, CollisionObject2D ── PhysicsBody2D ── CharacterBody2D ...
│ └── Control ── Button, Label, Container ...
├── Node3D ── MeshInstance3D, Camera3D, CollisionObject3D ...
├── AnimationMixer ── AnimationPlayer, AnimationTree
└── Timer, HTTPRequest, AudioStreamPlayer ...
Object └── RefCounted └── Resource ── Texture2D, PackedScene, AudioStream, Material ...4.2 Scenes
A scene is a tree of nodes saved to a file (.tscn, text; or .scn, binary). A scene has exactly one root node. Scenes can be:
Run on their own (great for testing).
Instanced (used as a child) in other scenes.
Inherited (a scene that extends another scene).
Typical decomposition:
Main (Node)
├── World (Node2D)
│ ├── TileMapLayer
│ ├── Player ← instance of player.tscn
│ └── Enemies (Node2D)
│ ├── Slime ← instance of slime.tscn
│ └── Slime
└── HUD (CanvasLayer) ← instance of hud.tscn4.3 The scene tree
When the game runs, the SceneTree (the main loop) holds a root Window (the viewport) whose child is the current scene, plus any autoloads:
Access it from any node with get_tree().
root (Window)
├── GameState (autoload)
├── AudioManager (autoload)
└── Main (current scene)4.4 Node paths
$Sprite2D # child named "Sprite2D" (shorthand for get_node("Sprite2D"))
$"UI/Health Bar" # quotes for names with spaces
get_node("../Enemy") # sibling via parent
get_node("/root/GameState") # absolute path
%HealthBar # scene-unique node (right-click node → "Access as Unique Name")
get_node_or_null("Maybe") # returns null instead of an error
get_parent()
get_children()
find_child("Gun", true, false) # recursive search by name (slow; avoid every frame)
owner # root of the scene this node was saved in4.5 Building your first scene (no code)
Create a scene, root Node2D, rename to Main.
Add a Sprite2D child; drag icon.svg into its *Texture* property.
Save as res://main.tscn; press F5 and accept it as the main scene.