Menu
CoddyTech

Node Paths

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

In this scene the eyes sit deeper in the tree. Face is a child of Robot, Eyes is a child of Face, and the two eyes are children of Eyes.

$Eyes finds nothing now, because Eyes is a grandchild of the robot. To reach it, write a path: the names on the way down, with a / between them.

get_node("Face/Mouth").position.y += 2
$Face/Mouth.position.y += 2   # the same, shorter

get_node() takes the path as text. $ is a shorter way to write it. A wrong path stops the game with Node not found.

challenge icon

Challenge

Easy

Make the robot look up and to the left. When the game starts, use get_node() to set the position of Face/Eyes to Vector2(-4, -3). Both eyes move with it. The face and the mouth stay put.

Try it yourself

extends Node2D

func _ready():
	pass
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