This project has moved and is read-only. For the latest updates, please go here.

Complete noob question - getting started

Topics: User Forum
May 31, 2009 at 10:33 PM

Hi guys,

I'm completely new to Farseer and I'm just having trouble getting started.  I made a new XNA game (3.0), and I added the FarseerPhysics ERngine as an additional project.  I wanted to gert a little basic practice using the engine so I decided I would make a character class.  I'm using namespace "WindowsGame1" (boring, I know). 


One thing that I had to do to get arround problems was delete the AssemblyInfo file.  Not a big deal.


Looking to the Spider.cs class as a guide I made the following character class:


private Vector2 position;
        private Body mainBody;
        private Geom mainGeom;
        private CollisionCategory collCat;
        private CollisionCategory collidesWith;
        private int collisionGroup;

        public Character(Vector2 position)
            this.position = position;
        public Body Body
            get { return mainBody; }
        public CollisionCategory CollisionCategory
            get { return collCat; }
            set { collCat = value; }

        public CollisionCategory CollidesWith
            get { return collidesWith; }
            set { collidesWith = value; }

        public int CollisionGroup
            get { return collisionGroup; }
            set { collisionGroup = value; }

        public void ApplyForce(Vector2 force)

        public void ApplyTorque(float torque)


Unfortunately, when I compile, I get the following error:

"The best overloaded method match for 'FarseerGames.FarseerPhysics.Dynamics.Body.ApplyForce (FarseerGames.FarseerPhysics.Mathematics.Vector2)' has some invalid arguments."


It's trying to use the XNA definition of Vector2 when the Body.ApplyForce( ) method is written to work with Farseer's Vector2 as an argument.


Maybe this is moire of a C# question than a Farseer question, but I would greatly appreciate it if someone could tell me what I'm doing wrong.  How can I get the system to just use one version of Vector2?


Many thanks,



Jun 1, 2009 at 12:52 AM

Ok, did you add the XNA version of the library? It sounds like you need to add XNA to the FarseerPhysics projects Conditional Compilation Symbols. Farseer has it's own copies of Vector2, Vector3, and Matrix by adding the conditional symbol you tell VS to use XNA's version. Try that and let me know if it works.

Jun 1, 2009 at 5:41 AM

Okay, I'll give it a try tomorrow afternoon, thanks for your help.

Jun 3, 2009 at 2:15 AM

Okay, I think that mostly worked, now I'm getting one error, and that's that the Calculator class doesn't exist in XNA, only the Farseer Mathematics library, and so now I'm getting errors in the Revolute Joint class (lines 181 and 186).  Obviously this is just me, so what stupid thing am I overlooking now?  Thanks for anyone's help, once again.



Jun 3, 2009 at 2:20 AM

There is a file called Calculator.cs inside the Mathematics folder. It should contain the Calculator class. If you accidentally deleted the file, just add it again from the Farseer Physics Engine 2.0.1 zip file.

Jun 3, 2009 at 2:25 AM

I must be doing something pathetically wrong.


I know that the class is there and I see that it's there.  This error appeared once I added XNA to the Conditional Compilation Symbols of my project, if that's any help.  The exact error is "The name "Calculator" does not exist in the current context"


The only other change that i've made is to delete the assemblyInfo.cs file, but that shouldn't matter, should it?

Jun 3, 2009 at 2:31 AM

The AssemblyInfo.cs file contains the assembly info (just like the name says). More specifically, it contains the version, name, description, copyright and GUID of the assembly. It's not needed to compile the project, but just keep it there.

If you send me your project, I can take a look at it. I'll contact you with my email and you can reply with your project.

Jun 3, 2009 at 2:32 AM

Okay, for now I have added a using in the Calculator class (even though the XNA symbol is now defined), so the Revolute class is using both XNA and Farseer libraries.


Now the compilation succeeds.  Thanks a lot genbox and mattbencher.


One last question though: adding the using statement feels like a bit of an unnecessary hack.  Is there any chance that I'll get another conflict of variable/method names by doing this?  My instinct is to say no, but I haven't thought it over too hard yet.

Jun 3, 2009 at 2:33 AM
Edited Jun 3, 2009 at 2:34 AM

Oh, you fixed it. Great.

I would still like to see how you managed to get the error, just in case we run into the same problem somewhere else.