Process Runs Every Frame
Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 7 of 28.
Godot draws a new picture of the game many times a second. Each picture is a frame. This game runs at 60 frames a second.
_ready() runs once. _process() runs on every frame, so 60 times a second:
func _process(delta):
position.y += 1That moves the node 1 pixel down on every frame, so 60 pixels each second. The steps are tiny, so you see a smooth slide.
Leave delta in the brackets for now. The next lesson explains it.
Challenge
EasyMake the robot slide right.
- In
_process(), replacepasswith a line that adds2toposition.x. - Keep the tab in front of it.
Press Play: the robot slides off to the right, 2 pixels every frame. Then Check.
Try it yourself
extends Node2D
func _process(delta):
pass
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