Hacker News new | ask | show | jobs
by IshKebab 1415 days ago
Why couldn't you just run physics at the graphics frame rate (or double it if the graphics becomes too slow)? I don't think many games need fully deterministic physics do they?

Like

    x += v * dt
    draw(x)
Or is that what this does?
1 comments

Collision detection is a major reason. If you only sample positions at the frame rate, you're going to have bullets go through walls without hitting anything.

Also, physics is costly to run, so usually it's not run on every frame.

And you really want your collision detection to be reasonably deterministic. Reasonable frame rates range from 30fps to 240fps, which is nearly an order of magnitude, and you want your bullets to behave the same over that range.
You only need physics to run at a "fast enough" rate. Let me rephrase:

Why not just snap physics frames to graphics frames?

Frame rate is variable.