Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to build a body with Farseer out of two rectangles so it looks like this:

enter image description here

I am a real beginner, so please describe it carefully.

Thanks in advance!

share|improve this question
I tried to make the shape out of the texture, but this hasen't worked. But I think the shape is not so complex, so I asked if it is possible to make this with 2 rectange. Making one big rectange works well, but the collision isn't very well, though the corners – Michael Jun 6 '12 at 14:14
What version of Farseer are you using? – Richard Marskell - Drackir Jun 6 '12 at 15:00
The newest: 3.3.1 – Michael Jun 6 '12 at 15:17
Create two rectangle fixtures, and attach them to the same body. One of the fixtures will have a rotation of 90 degrees, in respect to the other fixture. – Jon Jun 6 '12 at 16:20
how do you do this? I haven't found this in the Farseers Documentation. – Michael Jun 6 '12 at 16:35
up vote 1 down vote accepted

There are two ways you can do this:

1. With Fixtures
I recommend doing it this way as it's much easier to manage. Here's the code with comments:

//Create the initial body + 1 fixture in the shape of a rectangle
// The fixture is 2 world units wide and 1 world unit high
Body body = BodyFactory.CreateRectangle(world, 2, 1, density);
//Create a new fixture on the body.
    //The new fixture is a PolygonShape (CreateFixture accepts a Shape parameter)
    new PolygonShape(
        //This method returns a list of vertices which represent the shape of the fixture.
        //  Note the parameters are HALF width/height and that we've set
        //  it up so it's already "rotated".
        PolygonTools.CreateRectangle(0.5f, 1)
    , density));
//Set up body data
body.BodyType = BodyType.Dynamic;

Note: I've spanned some lines in order to explain what's going on, you obviously don't need to do this.

2. With Bodies
You should also be able to weld two bodies together like this:

//Create the first body with a width of 3 and height of 1
Body part1 = BodyFactory.CreateRectangle(world, 3, 1, density);
//Create the second body
Body part2 = BodyFactory.CreateRectangle(world, 3, 1, density);
//Rotate the body by pi / 2 radians (90 degrees)
part2.Rotation = MathHelper.PiOver2;
//Use a weld joint to stick them together
JointFactory.CreateWeldJoint(world, part1, part2, Vector2.Zero, Vector2.Zero)
share|improve this answer

You should be able to create a Body with 2 Fixtures attached if Farseer follows what Box2D does.

I've never used Farseer but the following is what can be done in Box2D and there should be something similar in Farseer:

Create 2 PolygonShapes using function below

void SetAsBox(float32 hx, float32 hy); //default centers each fixture at center of body

For example tallRect and wideRect are PolygonShapes


Create two Fixtures, one for each shape and attach both shapes to your Body using


I created something like this: enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.