Introducing fixed-timestep systems to 2B2D


I won't lie; I fought it for a long time. If delta time is good enough for animations, it should be good enough for everything! I resisted the idea of running physics systems in their own little schedule, disconnected from the reality of framerates. In theory, I should be able to calculate everything perfectly, just knowing how long the last frame took. Right?

Maybe, but probably not. I suppose it may be possible in very simple scenarios to have your physics calculated at the fluctuating whims of requestAnimationFrame timing, but in reality... it's just easier to not.

So I've added the ability to run systems at a (roughly) fixed framerate. The technical details are documented in the readme, but the short version is that this was by far the easiest way to fix the sluggish movement on high refresh rate displays. The character now seems to move and respond at roughly the same rate on my old laptop with the 60hz refresh rate as it does on my fancy new laptop with the 165hz (yeesh!) refresh rate.

It still feels a bit like a hack but I recognize the wisdom in it.  It really is much simpler to not have to worry so much about delta time. Things are more stable. Calculations work out better. Things are less finicky. In short, it just works.

And if you really hate it, you don't have to use it. I won't judge either way.

Files

3.1.0.zip Play in browser
61 days ago

Leave a comment

Log in with itch.io to leave a comment.