SFML community forums

Help => General => Topic started by: MrPlow442 on July 11, 2013, 07:19:48 pm

Title: A couple of questions regarding SFML and Box2D
Post by: MrPlow442 on July 11, 2013, 07:19:48 pm
I wasn't sure where to post this so my apologies if I posted this in the wrong subforum. But I have a couple of questions regarding SFML used in conjuction with Box2D.



Test code: https://gist.github.com/MrPlow442/5977338 (https://gist.github.com/MrPlow442/5977338)
Title: Re: A couple of questions regarding SFML and Box2D
Post by: zsbzsb on July 12, 2013, 12:46:34 am
Sorry I can't help with #1 as I haven't used Box2D enough. But as for #2 and #3 you should implement a fixed time step. Physics engines like Box2D work best with a fixed time step. I would say go with a fixed step between 10-20ms. You should take a look here (http://www.unagames.com/blog/daniele/2010/06/fixed-time-step-implementation-box2d) at this famous post about time steps.
Title: Re: A couple of questions regarding SFML and Box2D
Post by: MrPlow442 on July 12, 2013, 04:12:43 pm
Thanks for the response.

I read the blog post but I'm somewhat puzzled with his use of smoothedPosition and smoothedAngle variables. He calculates them but doesn't show how they're used. I assume that the body's position and angle are set to those values, or perhaps those values are applied to the render body/sprite? If that is the case wouldn't then the physical body and the sprite be a bit out of sync? Anyway since he doesn't show when and where he updates the body position and angles I have no clue what to do with those values. The fact that he's done it as a part of a component system doesn't help alleviate my confusion.

Got any advice on this?