Jump to content
  • Advertisement
Sign in to follow this  

Box2D is acting weird

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

If you intended to correct an error in the post then please contact us.

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
Maybe you fell for the other common trap: Don't give object sizes in pixel, give them in natural values.

It's a comment in the Box2d docs somewhere deeper, while it should be in bold red, blinking on top.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!