Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Godot - set_fixed_process function

I am trying to understand Godot Game engine, I am following a tutorial, and I wrote a breakout game. Here is the padding code:

extends KinematicBody2D

func _ready():
    set_fixed_process(true)

func _fixed_process(delta):
    var y = get_pos().y
    var x = get_viewport().get_mouse_pos().x
    set_pos(Vector2(x,y))

And I don't understand why I can't use the _fixed_process function without the set_fixed_process function, and what is it's use. What does the function do?

like image 637
user193464 Avatar asked Jul 16 '26 16:07

user193464


1 Answers

The _fixed_process() function is a callback that is enabled by calling set_fixed_process(true). This is just like how _process() isn't called unless you enabled the callback with set_process().

Both functions are essentially telling Godot that you want to receive those callbacks in your script when the nodes are processed. And then you're just overriding the _fixed_process() function to capture it in your script.

like image 164
Cody Parker Avatar answered Jul 21 '26 15:07

Cody Parker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!