Sign in to follow this  
Endurion

Sphere, Friction and variable time steps [SOLVED]

Recommended Posts

Hi, i'm working on a Marble Madness type game and got a dumbed down physics system working pretty well. What i'm having trouble with are varying frame rates. In fullscreen i'm vsynced to 100 Hz, in windowed mode i may get up to 350 Hz. This leads to some problems as the ball is not able to get up slopes in windowed mode will it's no problem in fullscreen. I'm aware that my "physics" are far from being correct, so i need a few hints. Right now i'm having a force vector (coming from mouse movement aka user input). Onto this vector i'm adding a slope vector multiplied by the grounds friction factor (to make the ball roll down a slope). Now in the balls update function i'm applying the force onto the balls speed vector. And that's probably where the problem lies: vectSpeed = vectSpeed * ( 1.0f - fElapsedTime ) + vectForce * fElapsedTime; This approximation seems close but as told above, it has it's turndowns. What would be the correct way to lerp the speed vector into the force vector with a variable time step value? Thanks in advance! [Edited by - Endurion on May 26, 2005 9:42:08 AM]

Share this post


Link to post
Share on other sites
This isn't really an answer to your question, but you probably should use constant time steps, then either limit your frame rate to that or use some kind of simple interpolation to render intermediate frames. Constant framerate makes your simulation a lot more predictable and you can easily make a playback feature that can be useful for debugging.

Share this post


Link to post
Share on other sites
Well, looks like i gotta cap the framerate. I hoped to come by without. Oh well.

Thanks though, interesting link as well.

What nobody ever tells, there has to be a solution formula wise actually? I see there'll probably be lots of precision and rounding errors making different frame rates still behave differently although the formula would be correct.

Rating++ for you!

Share this post


Link to post
Share on other sites
1337 - what a wonderful rating you have ;)

you don't need to fix your graphics framerate... only the physical one... just in case that wasn't clear :)

Share this post


Link to post
Share on other sites
Arghhhhh, i need to shoot myself.

After changing the physics to timestepped it still didn't work out. After further investigation i found that i applied the elapsed time onto the mouse movement before setting it to the object force. Grand. Meaning higher frames would lessen the users "power".

Things work fine now! Thanks again!

Squirm (Leonard?): Two days ago i had both rating and post count on 1337. But i couldn't post a brag thread in the lounge, it would've changed it :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this