Reputation: 1928
Initially when I was using _physics_process()
to control my KinematicBody2D
I was getting some minute but noticeable (and really irritating) jittering so I increased the physics fps to 144:
and this fixed the jittering ( Finally inner peace! )
However my pc is fairly high end and my monitor being 144hz
but would the game work the same (or at all) on lower end pcs with lower frame rate monitors? like what would be the overall effect of increasing the fps?
Also is it possible to change this property during runtime so if the user does have a lower end pc they can adjust the fps in the game accordingly?
Upvotes: 1
Views: 1773
Reputation: 40075
A high physics rate in a lower PC could mean wasted effort. Because a lot of the CPU time goes into motion that is not shown. And yes, that could be a performance problem for lower end PCs.
The recommended approach is to use Physics Interpolation which sadly Godot only has for 3D.
If you want to roll your own physics interpolation the idea is simple:
_process
._physics_process
.There two ways to do that:
As you know, we usually parent the graphic nodes to the physics nodes. If we want to move them independently we need to break that relationship. To do that you can use set_as_toplevel
.
If you want to have control over the physics rate see Engine.iterations_per_second
and Engine.target_fps
. I have not experimented setting these in runtime.
And, of course, correct use of delta
would be even more important. Consider if you need to use Verlet integration to apply accelerations.
Upvotes: 1