Skip to content

Lesson 1 of 9 · 24m

The Scene Tree Is the Game

Understand nodes as runtime objects in a live tree, not as files or decorative containers, and learn which lifecycle callbacks actually matter.

The worst Godot code I inherit treats nodes like loose variables instead of objects in a living tree. Godot's running game is the scene tree: ownership, order, visibility, processing, and lifetime are all tree behavior. Once that mental model clicks, the engine stops feeling magical and starts feeling inspectable.

Nodes are objects with a location

A Node has a parent, children, a name, and callbacks driven by the tree. More specialized nodes add capabilities: Node2D adds transform, CharacterBody2D adds movement semantics, and AnimationPlayer adds playback. You compose behavior by arranging those objects.

Main (Node)
├── World (Node2D)
│   ├── Player (CharacterBody2D)
│   └── Spawner (Node2D)
└── UI (CanvasLayer)
    └── HUD (Control)

The useful question is not merely "what type is Player?" It is "where is Player, who owns it, and who is allowed to know it exists?"

Learn the lifecycle boundaries

Godot calls lifecycle methods at specific moments:

func _enter_tree() -> void:
    pass

func _ready() -> void:
    pass

func _process(delta: float) -> void:
    pass

func _physics_process(delta: float) -> void:
    pass

_ready runs after children are ready, so it is a good place for local wiring. _process runs once per rendered frame. _physics_process runs at a fixed timestep and is the correct home for movement, collision, and simulation-sensitive gameplay.

Delta time is not optional

New developers write this and wonder why the game changes at 144 Hz:

position.x += 200.0 # pixels per frame: wrong units

Use units per second:

position.x += 200.0 * delta

Even then, visual interpolation belongs in _process; physics-sensitive motion belongs in _physics_process. Mixing them produces jitter, tunneling, and behavior that changes when the physics tick rate changes.

Inspect the running tree

The editor scene dock shows your design. The debugger's remote scene tree shows the truth: spawned enemies, orphaned nodes, editor helpers, and exact runtime names. When get_node fails, inspect the remote tree before adding another fragile path. Most missing-node bugs are ownership or timing bugs wearing a path-shaped costume.

Field notes

  • _init runs before the node enters the tree, so children and scene paths are unreliable there.
  • Use queue_free during callbacks; immediate free can delete objects the engine is still using.
  • Node paths are contextual, and ../Player changes meaning after reparenting.
  • Process mode decides whether pause affects a node; do not spray if paused through every script.
  • If a child must exist before _ready, make it part of the scene instead of creating it later.

Was this lesson helpful?

Sign in to rate