Menu
CoddyTech

The Scene Tree

Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 4 of 27.

Nodes are arranged in a tree. A node can have children, and each child can have children of its own. Open the Scene tab under the game to see the tree. Main holds the background, the floor and the Robot. The robot holds its antenna, bulb, body, face, eyes and mouth.

Children move with their parent. When the robot moves, its eyes move too.

name is a node's name, and get_child_count() counts its children:

print(name, " has ", get_child_count(), " parts")
challenge icon

Challenge

Easy

When the game starts, make the robot print Robot has 7 parts, using name and get_child_count().

Try it yourself

extends Node2D

func _ready():
	print(name)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Nodes and Scenes

Practice on your own: Godot playground