Menu
CoddyTech

Delta

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

Not every computer draws 60 frames a second. A fast screen draws 144, and a busy phone may draw 30. A robot that moves 2 pixels a frame is fast on one and slow on the other.

Godot passes delta to _process(delta) on every frame. It is the seconds since the last frame: about 0.0167 at 60 frames a second, about 0.033 at 30.

Multiply a move by delta to make it a move per second:

func _process(delta):
	position.y += 60 * delta

That moves the node 60 pixels each second on every computer.

challenge icon

Challenge

Easy

Make the robot move right at 100 pixels a second, using delta.

Try it yourself

extends Node2D

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