Where should I handle input and such?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rogerdv

Should I use _physics_process() or _process() ?

:bust_in_silhouette: 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

:bust_in_silhouette: 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