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 * deltaThe sign picks the direction. += moves right on x and down on y. -= moves left on x and up on y.
Challenge
EasyThe 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
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Nodes and Scenes
1Your First Godot Game
What Is Godot?Ready Runs OncePrint in GodotThe Scene TreeSet a PositionMove a Node Once2Every Frame
Process Runs Every FrameDeltaPixels per SecondMove DiagonallySpin With RotationGrow With ScalePractice on your own: Godot playground