Sign in to follow this  

Box2D is acting weird

Recommended Posts

Hi im a new member of Gamedev, and im having a problem with Box2D and SFML.

I recently(2 Weeks ago) began learning Box2D and when i start my test program it simulates too quickly I think its because of the b2World Step function getting the wrong TimeStep.

My Framework is set up to use the class WindowManager for everthing related to the RenderWindow. I made a function inside it called GetFrameRate and it returns the framerate.

This is the code i use for the handle function in my PhysicsHandler class

void PhysicsHandler::Handle(float FrameRate)
if(FrameRate < 0.1)

float TimeStep = 1.0f/FrameRate;
const int VelocityIterations = 15;
const int PositionIterations = 12;

PhysicsWorld->Step(TimeStep,VelocityIterations, PositionIterations);

So it takes 1 divided by the FrameRate returned from GetFrameRate()

Im really stuck.

Share this post

Link to post
Share on other sites
From Box2D manual : [url=""][/url]

"[font=Calibri, sans-serif][size=2]We also don't like the time step to change much. A variable time step produces variable results, which makes it difficult to debug. So don't tie the time step to your frame rate (unless you really, really have to). "[/size][/font]

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