The _process method
- Game Development course
- Beginner
- Lesson 77/83
- 4 min
Learn to run code every frame with _process.
_process(delta) and Game Loop
_process(delta) is the function called on every frame in Godot's main game loop. Continuous movement, keyboard and mouse inputs, or constantly changing counters are updated inside this function.
extends Node2D
func _process(delta: float):
position.x += 100.0 * deltaFrame-Rate Independent Movement
Games can run at different frame rates such as 30, 60, or 144 FPS across different hardware. Multiplying movement by delta normalizes the distance traveled per second, ensuring the game runs at the same speed on every computer.
extends Node2D
var hiz: float = 250.0
func _process(delta: float):
position.y += hiz * deltaPractice Define _process and _ready
Define the _process(delta) function with pass in its body. Inside _ready(), print print("Döngü hazır").
Starter code
extends Node2D
# _process(delta) fonksiyonunu tanımla
func _ready():
# "Döngü hazır" mesajını yazdır
passSample solution
extends Node2D
func _process(delta):
pass
func _ready():
print("Döngü hazır")Expected output
Döngü hazır
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does the delta parameter passed to the _process(delta) function represent?
- Time elapsed since the last frame in seconds Correct answer
- Total count of nodes in the scene tree
- Total frame count in the game
- Aspect ratio of the screen resolution
Explanation: delta represents the time elapsed from the previous frame to this one (in seconds).
2 _process function parameter
extends Node2D
func _process(____):
pass
extends Node2D
func _process(delta):
pass
Explanation: The _process function takes the delta parameter indicating elapsed time.
3 Game Loop Components
| Term | Meaning |
|---|---|
_process() |
Loop function called once per frame |
delta |
Time elapsed between two frames |
FPS |
Frames processed per second |
Bağımsız hareket |
Frame-independent speed using delta |