Open aaratha opened 1 week ago
I don't think there is any automatic way, but it should not be too hard to use get_time()
and wait until the next physics tick for the appropriate time using sleep()
. I use a tick debt system, so when one tick takes a little longer than it should, the other one will not sleep for as long to compensate this.
Yeah, this seems to be the only way... I don't think sleep() works in WASM, though.
A better way to do this (if fps is too high) is to keep rendering without updating physics, so for example you render 2 frames for 1 physics update. And if fps is too low, you do the opposite - update physics multiple times every frame.
Oh, so I could have a couple fps ranges (58-62, 68-72, 88-92), for instance, and modify the processes based on checks against those? That sounds like it could work.
I am compiling my game to WASM and hosting it on itch.io, and I've noticed that the speed at which it runs is completely different depending on the refresh rate of the device I'm using. It runs fine on my computer, but runs way too fast on my Android with 90hz. Is there any sort of automatic way to lock the physics process to 60hz?