Keeping physics consistent with various framerates

I feel like I must be missing something obvious since every game ever released has to deal with this.

I’m making a game where the player controls a boat using physics. It’s nothing too complicated yet, however. Although at 60 FPS everything works properly, at 50 FPS or lower, the boat starts to violently jitter back and forth until it shoots off the map with the speed of a thousand suns. The lower the FPS is, the quicker this happens.

On the other hand, the higher the FPS goes, say 120 FPS, everything acts like its in slow motion. The boat, or any other physics items fall down as if they’re on the moon, and it takes forever to gain momentum to move forward. Also any spinning objects turn at half the speed.

I’ve searched a lot about this, and every topic I come across says I simply need to turn on Substepping. And the lower the delta time with higher substeps, the more fixed the physics become at the cost of higher CPU usage.

Although this indeed fixes the violent jittering and subsequent launching into orbit at lower framerates, it’s still nothing near to how the physics act at 60 FPS. Everything simply goes at nearly the same pace as if it were 120FPS. Also, when set at 120FPS, there is no change in the speed whatsoever. Everything still goes in slow motion.

Added to that. Whenever I add substepping, even at 60FPS, the boat suddenly heaves over toward the direction it is moving. Something it doesn’t do when substepping is disabled at 60FPS.

So basically, I’d like to learn what I need to do to make everything act the same regardless of the framerate. Some topics mentioned the use of delta time in the control input, but that doesn’t fix stuff like gravity. Besides, that would mean that every moving or animated object would manually need to be set to support different framerates.

I feel like I’m missing something fundamental. How can I set up the game so that the physics behave consistently? Would fixing the framerate to 60FPS solve it, or would that be problematic for lower spec PC’s that cannot deliver that performance?

1 Like