The Engine Model: Nodes, Scenes, the Tree

Module 1 ยท Lesson 1 ยท ~30 min ยท Godot 4.x

Before you touch GDScript, you need the mental model. Godot is aggressively componential, and almost every confusion newcomers have comes from trying to impose patterns from other engines (or worse, from MVC web frameworks). Ten minutes of model correction here saves ten hours of "why isn't this working" later.

The three concepts

ConceptWhat it isSWE analogue
NodeA unit of behavior. Has a name, a parent, children, and a type.Component. Or a React element. Or an Actor.
SceneA reusable tree of nodes, saved as a .tscn file.A reusable component bundle. A prefab. Think "React component definition saved to disk."
SceneTreeThe live, running hierarchy of all instantiated nodes in the game.The DOM. Actually yes โ€” Godot even has get_node("Player/Hand/Card") which is basically querySelector.
A scene is a class. An instance of that scene in the running game is an object. The SceneTree is the runtime heap holding all those objects, wired together as a tree by parent-child relationships. If you internalize just this, you're 60% of the way there.

Nodes are the unit of composition

Everything in a Godot game is a node. A sprite is a node (Sprite2D). A camera is a node (Camera2D). A text label is a node (Label). A physics body is a node (CharacterBody2D). A timer is a node (Timer). Scripts attach to nodes.

There are hundreds of built-in node types. You compose them into trees:

Card (Node2D)
โ”œโ”€โ”€ Background (Sprite2D)
โ”œโ”€โ”€ LetterLabel (Label)
โ”œโ”€โ”€ ValueLabel (Label)
โ””โ”€โ”€ TouchArea (Area2D)
    โ””โ”€โ”€ CollisionShape (CollisionShape2D)

That's a card. Five nodes. No new classes required โ€” you configured existing types and saved the tree as Card.tscn.

Scenes are reusable trees

A scene is a serialized subtree. When you save Card.tscn, you can instance it anywhere โ€” load it by filename, stamp out copies, place them in a Hand node. Each instance is independent. Modifying one doesn't affect the others. Modifying the .tscn file does affect all future instances (and, if they inherit, existing ones).

This is where Godot diverges sharply from code-first engines. You don't instantiate scenes in code except when strictly dynamic. For static hierarchies, you drag a scene into another scene in the editor, and the editor serializes the composition. The editor is the composition tool; code is behavior.

Rule of thumb If a thing exists from scene-start, place it in the editor. If a thing appears dynamically (an enemy spawns, a card is drawn from the deck), instance it in code. Both are normal. Don't do everything in code โ€” it's slower to build and harder to tweak.

The SceneTree at runtime

When the game runs, Godot maintains a single SceneTree. The root is typically a Window with your main scene hanging off it. Everything you can see or tick is somewhere in that tree.

Every frame, Godot walks the tree and calls two methods on every node that defines them:

func _process(delta: float) -> void:
    # Called every rendered frame. delta = seconds since last frame.
    pass

func _physics_process(delta: float) -> void:
    # Called on a fixed physics tick (default 60Hz). Use this for movement.
    pass

There's also _ready() (fires once when the node enters the tree), _input(event) (fires on input events), and a few others. These are hook methods โ€” you override them in your script to inject behavior.

If you've written React with useEffect(() => {...}, []) and useEffect(() => {...}), you've written _ready and _process. Same idea: lifecycle hooks on a tree node.

Main scene and the project

A Godot project is a folder with a project.godot file. It has exactly one main scene โ€” the one that loads when you hit Play. Everything else is instanced from or navigated to from there.

You'll set this up in the next exercise. For now, understand: one project, one main scene, many scenes instanced inside it.

Terminology you'll trip over

TermWhat it means
InstanceAn in-memory copy of a scene placed into the tree.
InstantiateVerb. The act of creating an instance, usually via PackedScene.instantiate().
ScriptA .gd file attached to a node. Adds behavior. Always extends a node type.
RootThe topmost node in a scene. Also the topmost node in the SceneTree.
OwnerWhich scene a node belongs to. Matters when you save or instance.
PackedSceneA scene loaded but not yet instanced. The "class" form of a scene.
AutoloadA scene or script that lives at the SceneTree root, globally. Godot's singleton pattern.

The editor is a tool, not the system

You will spend most of your time in the Godot editor: dragging nodes, tweaking inspector values, attaching scripts. That's normal and healthy. But under the hood, every editor action is serializing data into .tscn and .tres files (both are INI-like text formats, which means they diff well in git). When things break or get weird, open the scene file in a text editor โ€” it's readable.

# Example of what a Card.tscn looks like on disk:
[gd_scene load_steps=2 format=3]

[ext_resource type="Script" path="res://scripts/card.gd" id="1"]

[node name="Card" type="Node2D"]
script = ExtResource("1")

[node name="Background" type="Sprite2D" parent="."]
position = Vector2(0, 0)
Why this matters Because scenes are text, they play nicely with version control. You can review diffs in PRs. You can merge conflicts. If you came from a binary-asset workflow, this is a small gift you'll appreciate.

What you should do right now

  1. Install Godot 4.3+ from godotengine.org/download. Pick the standard build (not .NET unless you specifically want C#).
  2. Launch it. Create a new project. Name it lexicon-duel and save it somewhere you'll remember.
  3. When it opens, you'll see the editor. The big panel in the middle is the viewport. Top-left is the Scene dock (the tree). Below it is the FileSystem dock. Bottom is the output log. Right is the Inspector.
  4. Hit Ctrl+S. It'll complain there's no scene. That's the next lesson.

That's the mental model. Next up: GDScript.