Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rogerdv |
Should I use _physics_process() or _process() ?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rogerdv |
Should I use _physics_process() or _process() ?
Reply From: | andersmmg |
You should probably use _input()
for most things, like single button presses, but when checking if a key is pressed (for example wasd keys), you should do it right before you do the actions for whatever they keys do, which will depend on your code
Reply From: | Zylann |
To receive input at the time it happens (button down, key pressed, mouse moved), use _input
, or _unhandled_input
if you have GUI nodes in your game.
To poll input anytime or every frame, use the Input
singleton. This one is most of the time used in _physics_process
if your game has physics, which runs every physics frame (solid 60 fps), otherwise _process
if you want it to run every graphic frame (but will mostly be 60fps too but framerate-dependent so use delta
).
For more details about input, see InputEvent — Godot Engine (3.1) documentation in English
And here for differences between _physics_process
and _process
: Node — Godot Engine (3.1) documentation in English