Farseer Physics weird collisions

316 Views Asked by At

I'm starting a game, and I'm using Farseer as the physics engine.

I have setup a few boxes acting as terrain tiles, and a box as the player. The collisions between these two are very weird, they intersect and slide when it's not a "direct" hit.

Here's a GIF of what's happening: http://i.imgur.com/HR0J0D3.gifv

And here are the snippets:

//Creating the body
PhysBody = BodyFactory.CreateRectangle(
    Transform.World.PhysWorld,
    ConvertUnits.ToSimUnits(Width * Transform.Scale),
    ConvertUnits.ToSimUnits(Height * Transform.Scale),
    5,
    ConvertUnits.ToSimUnits(Transform.Position.ToVector2()));

//The tiles are static, the player is not
PhysBody.BodyType = Static ? BodyType.Static : BodyType.Dynamic;

//Drawing the test rectangles
ShapeRenderer.Instance.DrawRectangle(
    sb,
    ConvertUnits.ToDisplayUnits(PhysBody.Position).ToVector2(),
    new Size2((int)(Width * Transform.Scale), (int)(Height * Transform.Scale)),
    Color.White);

I don't think the rest is important, all I did was create a world with 9.8 gravity.

I have also tried without using Transform.Scale and with just one box below the player, and the problem still happens.

The graphics engine I'm using is Ultraviolet

0

There are 0 best solutions below