# Sphere, Friction and variable time steps [SOLVED]

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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.

Gaffer's article

##### 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 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 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 :)

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 13
• 10
• 12
• 10
• ### Forum Statistics

• Total Topics
633001
• Total Posts
3009821
• ### Who's Online (See full list)

There are no registered users currently online

×