Live data from Hacker News

Doing Game Gravity Right

niksula.hut.fi

41–50 of 86 posts

Re: Doing Game Gravity Right

#41
You can cut down the amount of error even further by not iterating. Instead of iteratively updating the height, just store the initial position, velocity and time. You still compute the current position as pi + vi * dt - a * dt * dt/2, but intermediate results are discarded to avoid compounding floating point errors.

Of course, you will need to update the initial position/velocity/time whenever the jump is interrupted or modified. The reduction in error is also quite small.

Re: Doing Game Gravity Right

#42

This isn't exactly a new development, as the article in question was first posted on May 13th, 2000.

Even if something was first published in 1969, some of us are seeing it for the first time. Anyhow, no one was claiming that this was a "new development".

Re: Doing Game Gravity Right

#43
post #21

Earlier quoted context omitted.

Yeah, in the perfect world all your buyers will have them. In real life sometimes don't. Plus there is a lot of things you don't know; maybe he haves the minimum requirements but he is running a lot of background process because he installed a bunch of things he doesn't use.

If the game is so bogged down that the fixed timestep cycle is slowing down the game is broken for so many other reasons. Objects will start tunneling through other objects.

Changing the discussion from conceptual to technical making assumptions in the latter just to win an argument. I like that.

Re: Doing Game Gravity Right

#44
post #38

Earlier quoted context omitted.

> Drops in framerate happen. No, they don't. Game logic should run at constant 60 or more fps, even when graphics framerate is lower: http://gafferongames.com/game-physics/fix-your-timestep/ But yes, it's an interesting article, and this method allows for a bit more accuracy.

So, why is it important to have a fixed deltaTime? Except in cases where determinism really does matter. I.E. lock-step based networking. Why is this important?

Determinism really does matter. You want it for debugging. Also for replays, if your game has that feature.

Re: Doing Game Gravity Right

#45
post #44
post #38

Earlier quoted context omitted.

So, why is it important to have a fixed deltaTime? Except in cases where determinism really does matter. I.E. lock-step based networking. Why is this important?

Determinism really does matter. You want it for debugging. Also for replays, if your game has that feature.

I think a significant amount of released games would argue that point pretty strongly.

Sure, it makes some things easier, but it comes at some cost.

Re: Doing Game Gravity Right

#46
post #13

This is still Euler integration, which has poor accuracy whenever the derivative varies with time. The standard numerical integration method is 4th order Runge Kutta. RK4 is also popular for solving many forms of differential equations. A good summary is here: http://gafferongames.com/game-physics/integration-basics/

> This is still Euler integration, which has poor accuracy whenever the derivative varies with time.

Which is why decoupling the physics delta from the rendering framerate is important. The author mentions Quake (id Tech 1, 2 or 3 ?), and I seem to recall id Tech 4 (Doom 3) was the first id Tech engine that implemented that.

Re: Doing Game Gravity Right

#47
post #23

you are still doing it wrong. dt should not be affected by framerate. http://gafferongames.com/game-physics/fix-your-timestep/ use an accumulator to have a fixed dt no matter the framerate. With a variable step size you risk all kinds of weird bugs linked to the hard to debug rendering context. The size of dt should be consider a system parameter, tuned for your game and fixed in concrete .

So what happens when the OS doesn't return to your process in dt time? The whole point of dt is to deal with variable framerate.

Then the game runs in slow motion. There's not much you can do on a slow system.

Or if you mean that you may be forced to draw at (for instance) 55fps, then the solution is to precalculate the next physics frame and linearly interpolate between the previous and next frame when drawing.

Re: Doing Game Gravity Right

#48
post #38

Earlier quoted context omitted.

> Drops in framerate happen. No, they don't. Game logic should run at constant 60 or more fps, even when graphics framerate is lower: http://gafferongames.com/game-physics/fix-your-timestep/ But yes, it's an interesting article, and this method allows for a bit more accuracy.

So, why is it important to have a fixed deltaTime? Except in cases where determinism really does matter. I.E. lock-step based networking. Why is this important?

Because without fixed deltaTime, if the framerate is too low, you can't jump in Quake. With the "new algorithm", in the 3fps example, you still have to luck out and get a tick at the right time.

And with a constant delta, if you choose it right, it can be easier to get collision detection right. You can possibly get away with checking if two things are colliding with each other right this tick instead of checking if they might have run through each other between ticks. With variable delta, if you want to get it right, you might have to check where things where half a frame ago and such, and at that point it might be easier to just check more often instead.

And I think you should probably ask the same question about variable deltaTime. Assuming that coupling rendering and game logic is not some best practice that you should default to, why would you want variable deltaTime? (There may or may not be some good answers to that, and maybe it totally depends on the game and so on.)

Re: Doing Game Gravity Right

#49
post #39

Can someone explain the jumping parabola graphs? I can't make sense of the description.

X is time, Y is height. So something like, X time after hitting the jump button, the guy is Y above the ground.

(Or you can pretend that the guy is moving towards the right at constant speed, and jumping, and the points in the graphs are the different positions he'll be at :)

(Edit: I'm not very sure about the pictures to the left though. Maybe higher jumps/longer time or somethingsomething.)

Re: Doing Game Gravity Right

#50
post #9

Earlier quoted context omitted.

Does sims 3 even have gravity?

The point being that it doesn't matter if you believe people will not play the game because game performance; if they really like it the will ignore it. And if they paid for your game you should at least try to give them an experience as good as possible.

I'd say it's still fair to point out that you chose a game where framerate is particularly unimportant to begin with.

Like, you probably would believe the amount of people playing Quake Live at 7 fps.

Post reply on HN