Godot Version
4.7
Question
I am interested to know what use cases _process() has in modern Godot.
We now have Physics Interpolation that can smoothen out movements triggered in _physics_process(), providing smooth but consistent behaviour.
We also have the two AnimationMixer node types, which allow for animations to be scripted without code.
I’m not saying there aren’t any use cases, I am just curious for some examples, even if they’re niche.
(for the record, the information in this post is based on my experience with 2D Godot. I’ve not touched 3D so my information may be inaccurate for that side of the engine.)
_process() is for visual frames.
There might be some cases where the interpolation will give you wrong tweened values on some effects, so you do the actual real value computation on _process().
You can run lighter stuff at over 100Hz on _physics process and run the rendering loop at 60hz for more accurate high-speed physics, or you can subsample expensive physics at 30Hz and enable interpolation up to 120Hz. Each game will have its own requirements.
For especially updating visual stuff, _process() results in a more responsive feel. For example, if you’re making a custom mouse cursor, having the code for it in _process() will give you a responsive mouse cursor because it updates the position each frame.
func _process() -> void:
mouse_cursor.global_position = get_viewport().get_mouse_position()
If you’re directly moving / rotating an object with code, for example a car wheel visual or a camera, rotating it in _process() will result in a much smoother visual rotation. But other than that, _physics_process() is the way to go in my experience.