Back

Activity 2.2: The Scene Tree, Coordinate Space, and Draw Order

divider

Activity 2.2

The Scene Tree, Coordinate Space, and Draw Order

Key Concepts

The Scene Tree

2D Coordinate Systems

Parent & Child Nodes

Draw Order

The Scene Tree

Every scene you build is really a small tree of Nodes. When your game runs, all of those smaller trees plug together into one big Scene Tree.

The Scene Tree

Diagram showing a Game root node with Player and Asteroids as children, and three Asteroid instances nested under Asteroids

2D Coordinate Systems

Every 2D game needs a way to describe where things are. Godot's isn't quite the same as the graph you'd draw in math class.

2D Coordinate Systems

Diagram showing Godot's 2D coordinate system with the origin at the top-left corner, X increasing to the right, and Y increasing downward

Parent & Child Nodes

A parent Node can hold child Nodes purely for organization — grouping related objects together under one empty Node2D keeps a busy scene tree readable.

Draw Order & Z Index

By default, Nodes later in the tree draw on top of Nodes earlier in the tree. Z Indexlets you override that, regardless of tree order.

Today's Objectives

  • Adding a second reusable scene (Asteroid) alongside Player
  • Reading and reasoning about Godot's coordinate system
  • Organizing nodes with an empty parent Node2D
  • Controlling what draws on top with Z Index

Key Terms

Scene Tree
The full hierarchy of every Node in a running game.
Coordinate System
The way a game represents position — in Godot, the origin (0, 0) is the top-left corner.
Parent Node
A Node that contains other Nodes as children.
Child Node
A Node contained within a parent Node.
Z Index
A value controlling draw order, independent of a Node's position in the tree.

'F' → Fullscreen

divider

Build

Continue working in the project from last activity.


Task 1: Add an Asteroid Scene

  • Watch: Section 2, Lecture 2.6 — The Scene Tree (05:45)
  • Build a new Asteroid scene — same pattern as Player: RigidBody2D root, Sprite2D child, CollisionShape2D child.
  • Instance a few Asteroids into your Game scene alongside your Players.
[GIF PLACEHOLDER — Building and Instancing the Asteroid Scene]

Task 2: Explore the Coordinate System

  • Watch: Section 2, Lecture 2.7 — 2D Coordinate System (05:07)
  • Drag your Player and Asteroid instances around the Viewport, watching their Position values change in the Inspector.
  • Note which direction increases X, and which direction increases Y.
[GIF PLACEHOLDER — Exploring Position in the Inspector]

Task 3: Group with Parent and Child Nodes

  • Watch: Section 2, Lecture 2.8 — Parent & Child Nodes (06:41)
  • Add an empty Node2D to your Game scene, named "Asteroids".
  • Move your Asteroid instances so they become children of "Asteroids" instead of children of "Game".
[GIF PLACEHOLDER — Grouping with a Parent Node]

Task 4: Control Draw Order

  • Watch: Section 2, Lecture 2.9 — Draw Order & Z Index (06:04)
  • Give your "Asteroids" group a Z Index of 50.
  • Give your Player instances a Z Index of 100, so Player always draws on top.
[GIF PLACEHOLDER — Setting Z Index]
divider

Checkpoint

You should see the following in the Godot editor:

  • The Scene panel shows "Asteroids" as a parent node, with your Asteroid instances nested inside it as children.
  • Your Player instances always render on top of any overlapping asteroids, regardless of tree order.
[GIF PLACEHOLDER — Final Scene Hierarchy and Draw Order]
divider

Reflection

Answer the following questions before submitting your work.

  1. In Godot's coordinate system, which direction does the Y-axis increase — up or down? How is that different from a graph in math class?
  2. What's one advantage of grouping several nodes under an empty parent Node2D, instead of leaving them all as direct children of the root?
  3. If two overlapping sprites are siblings in the scene tree, which one draws on top by default — and how can Z Index change that?
divider

Submit

Submit the required files to the appropriate dropbox.

Activity Complete