The Dollar Sign
Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 19 of 27.
To change one of the robot's children, the script first has to find it. Write $ and the child's name, as it is shown in the Scene tab:
$Bulb.position.y -= 6That lifts the bulb on the antenna and leaves the rest of the robot in place. $Bulb is the node, so you can read and change anything on it.
A child's position is measured from its parent. The left eye is at x = -13, 13 pixels left of the robot's middle.
Names must match exactly, capitals included. $lefteye finds nothing.
Challenge
EasyMake the robot look to the right. When the game starts, move LeftEye and RightEye 4 pixels right each. The robot itself stays put.
Try it yourself
extends Node2D
func _ready():
pass
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