Jump to content
  • Advertisement
Sign in to follow this  
CTheInitiator

Box2D is acting weird

This topic is 2566 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)
return;

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!