Search code examples
c#box2dphysicsrectanglesfarseer

Farseer/Box2D Rectangles going crazy after hitting floor


I'm using Farseer Physics and creating my bodies like so:

Body = BodyFactory.CreateRectangle(_world,
  PixelToPhysics(Width),
  PixelToPhysics(Height),
  Density
  null);

And as you can see on the following gif -

Physics going crazy

the rectangles behave normally and collide as they should until they hit the floor. The floor itself is a rectangle too, but its body type is set to Static.

I've tried playing around with the timestep and scale but that doesn't seem to be the problem. Also, I don't think it's a rendering glitch since it behaves as it should before hitting the floor.

To me, it seems that upon hitting the floor their size changes, but I can't seem to be able to debug it.


Solution

  • The timestep was (1000 / FrameTime) instead of (FrameTime / 1000) making physics move by 60 seconds per step rather than 0.016ms.