Jump impulse with lower frame rates

Hey Guys,

I've been testing my app with lower update speeds, and everything seems to be working fine except for my character's jump height. To jump, first I set the y velocity to 0, and then apply an impulse in the y direction. At lower frame rates (I just threw a sleep(100) in my main loop to test) the character doesn't jump as high... probably a little less than half the height he normally does.

I'm not quite sure what could be causing the impulse to have a lesser effect on the body at slower frame rates. Any thoughts to what I should be checking? I've already verified that my gravity isn't greater at lower frame rates, and I'm pretty confident that's the only force being applied in the y direction.

Also, my implementation of my updating my physics is very similar to: http://www.unagames.com/blog/daniele/20 ... tion-box2d . My gravity is being applied at the same time the "updateControllers_" is called, and my jump impulse is applied in my keyboard callback function.

Any advice is welcome, thanks in advance.

-Dave
I'm just a novice at this, but I have some suggestions.

So, if you only add "sleep(100)" in your main loop, the player doesn't jump as high as before? That means there is something else messing with the bodies, because the simulation should be the same regardless of when you call world.Step(). Are you sure you are calling with the same arguments (timeStep, velocityIterations, positionIterations)?

I skimmed over that article you linked to. Basically you are displaying a "smoothed" version of the bodies' movements, right? Are you sure that the player doesn't appear to jump lower precisely because of this smoothing combined with the lower frame rate? Check the body's position from the Box2D world after each step (e.g. print it to the console) and check if it really is jumping lower.
Hm...

timeStep, velocityIterations, positionIterations are all constant.

I dont think it's not an issue with the smoothing. That's the interpolation portion of the "fix your timestep" article. The player jump drastically less than he should be (less than half as high). I disabled the smoothing just to check and it didn't change the results I've been seeing...

Still not quite sure what the issue is, thanks for the ideas though.

-Dave
EDIT: Ah-ha!

It's got something to do with setting SetAutoClearForces to false, and instead calling ClearForces() after N number of updates. More investigation needed.

-Dave

Original thread: https://box2d.org/forum/viewtopic.php?t=5752