Menu
CoddyTech

Move a Node Once

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

Setting position puts a node in an exact place. To move it by an amount from where it is, change position.x or position.y. += adds to a number:

position.x += 100

That moves the node 100 pixels right. -= subtracts, so position.y -= 50 moves it 50 pixels up. Remember that y grows downward.

A move by an amount works wherever the node starts.

challenge icon

Challenge

Easy

When the game starts, move the robot 150 pixels left and 40 pixels up from where it stands. Move it by amounts with += or -=.

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