This project has moved. For the latest updates, please go here.

Farseer 2.1.3 Question regarding pin joints

Feb 17, 2011 at 2:09 PM

I'm aware that this is an old version and may no longer be supported, but other components I'm working with are on XNA 3.1 so I can't use the more up to date engine. I'm completely stuck. I can't figure out how to create pin joints (or any joints for that matter). The documentation doesn't explain the syntax or offer up any code examples, just a Silverlight demo (with no code) which is pretty useless. The demos that come with code aren't properly commented so I can't figure it out from them.

What I'm trying to do:

I want a fixed object that'll rest above another object. I want them to be connected with a pin joint (or some other joint that'll keep them at a fixed distance). I want the second, non-fixed object to swing down like a pendulum. Is this possible? How do I do this?


Thanks in advance,


Feb 17, 2011 at 2:44 PM

I can't really help you with your problem, cause personally I shifted to 3.x as soon at it was available. What I can tell you though is that 3.x works perfectly fine with XNA 3.1

The only thing that does not work are the samples and even those just fail because of the changed content project structure in XNA 4.x which can easily be changed back to the old XNA 3.x structure. So if you are not too far into your physics implementation switching may be a viable option for you.

Feb 17, 2011 at 3:00 PM

How do you add it to a 3.1 project? When I attempt to do so I get an error that reads "The referenced component 'FarseerPhysicsXNA' could not be found."

Feb 17, 2011 at 3:29 PM

What are you trying to add? Just copy the "Farseer Physics Engine 3.2 XNA" folder somewhere and add the "Farseer Physics 3.2 XNA.csproj" to your solution. Then add a reference to the Farseer Project in your Solution to your game project and you should be fine. Additionally do the same for the Debug View if you need it.

Feb 17, 2011 at 11:23 PM

But I can't do that, I'm using Visual Studio 2008 because I'm working with XNA 3.1. The Farseer project is a VS 2010 project and I get loads of errors when I try to import it.

Feb 18, 2011 at 3:26 AM

Hello Brett,

This may or may not help your situation but XNA is no longer accepting 3.1 submissions IF you are looking to distribute via App Hub.
I'd download the latest free tools (VS2010 express etc) and switch up to the latest Farseer.

This link explains it and also provides the download for the free tools:

As for the joint... I used this for a hanging light that I anchored to the border (ceiling):

        public override void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator, Border border, Texture2D texture)        {
            base.Load(graphicsDevice, physicsSimulator, texture);
            Body = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, Texture.Width, Texture.Height, 1);                    Body.Position = Position;            Body.Mass = 5;            Body.LinearDragCoefficient = Body.Mass / 3;
            Geom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, Body, Texture.Width, Texture.Height);            Geom.CollidesWith = CollidesWith;            Geom.CollisionCategories = CollisionCategory;            Geom.FrictionCoefficient = 4;
            AnchorPoint = new Vector2(Body.Position.X, border.TopBorder.Position.Y + ( border._borderWidth / 2));            revJoint = JointFactory.Instance.CreateRevoluteJoint(border.TopBorder.Body, Body, AnchorPoint);            physicsSimulator.Add(revJoint);            _lineBrush.Load(graphicsDevice);        }

     public override void Draw(SpriteBatch spriteBatch)        {            _lineBrush.Draw(spriteBatch, AnchorPoint, Body.Position);            spriteBatch.Draw(Texture, Body.Position, null, Color.White, Body.Rotation, Origin, 1f, SpriteEffects.None, 0f);        }

Best of luck,