Menu
CoddyTech

Move a Node Once

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

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

Move the robot from where it stands when the game starts.

  1. In _ready(), move it 150 pixels left with -= on position.x.
  2. Then move it 40 pixels up, on position.y.

Press Play: the robot starts up and to the left of the middle. Then Check.

Try it yourself

extends Node2D

func _ready():
	pass

All lessons in Nodes and Scenes

Practice on your own: Godot playground