Menu
CoddyTech

Pixels per Second

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

With delta, the number in front of it is a speed in pixels per second. A walk is about 150 pixels a second, a dash about 500.

To cross a distance in a set time, divide the distance by the time:

# 400 pixels in 2 seconds is 200 pixels a second
position.x += 200 * delta

The sign picks the direction. += moves right on x and down on y. -= moves left on x and up on y.

challenge icon

Challenge

Easy

The robot starts at x = 320. Make it reach x = 20 in 2 seconds, at a steady speed. Work out the speed first.

Try it yourself

extends Node2D

func _process(delta):
	position.x += 100 * delta
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