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

Confusion between XNA Vector2 and Farseer Vector2

Feb 3, 2009 at 2:10 PM
Hey guys!

I've almost got a new project set up combining Farseer Physics with the XNA Game State Management example, but I'm left with one error when I build.

One of my classes throws "Cannot implicitly convert type 'Microsoft.Xna.Framework.Vector2' to 'FarseerGames.FarseerPhysics.Mathematics.Vector2'".

Any ideas what the problem might be?

Here's the "using" statements from the class:

#region using statements;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    using Microsoft.Xna.Framework.Audio;

    using FarseerGames.FarseerPhysics;
    using FarseerGames.FarseerPhysics.Collisions;
    using FarseerGames.FarseerPhysics.Dynamics;
    using FarseerGames.FarseerPhysics.Dynamics.Springs;
    using FarseerGames.FarseerPhysics.Factories;
    using FarseerGames.PhysicsMusicToy.DrawingSystem; // Adapted from the DrawingSystem in the Farseer examples

And the code that throws the exception:

public Vector2 position
                    return this.body.Position;
                    this.body.Position = new Vector2(value);
Feb 3, 2009 at 4:05 PM
It seems that I forgot to remove the Vector2, Vector3, Matrix and Mathhelper classes from the XNA releases. If you download the release again, it should be fixed.

Thanks for reporting this. I will try to ensure a better release quality in the future.
Feb 3, 2009 at 4:34 PM
Thanks genbox!

All this time I thought I was missing something.  Good to know I'm not completely useless! ;)
Oct 8, 2009 at 3:17 PM

It seems the problem is still in the release somehow. I get the exact same error for the same reasons. Tried to remove various Math-files from FarseerPhysics project but with no luck. Suggestions?

Oct 8, 2009 at 4:07 PM

The math files only exist in the non-XNA versions. What version are you using? If you are able, could you send me your project so I can take a look at it and see what the problem is? (click my username and click contact - I will reply with my real email)

Oct 9, 2009 at 10:00 AM

No worries. I might have downloaded a non-Xna one. I'll download the correct one and see what happens.