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

Rotation problem in 3.2

Topics: Developer Forum, User Forum
Jul 23, 2011 at 4:37 PM

I'm using farseer 3.2 and i have a body who's rotation i continuosly set manually, so that it is facing the mouse. The object is viewed by a camera (TLCorner is the top left corner of the camera's view.) The problem is that if i move this object about by applying force to it and spin it a bit by rotating the mouse round the circle, the accuracy of the rotation slowly goes out a little bit. It's rotation is set like this

circleBody.Rotation = StaticHelpers.TurnToFace(ConvertUnits.ToDisplayUnits(circleBody.Position),
                new Vector2(Mouse.GetState().X + cam.TLCorner.X, Mouse.GetState().Y + cam.TLCorner.Y)) +


Where TurnToFace() looks like this:

       public static float TurnToFace(Vector2 position, Vector2 faceThis)
            float x = faceThis.X - position.X;
            float y = faceThis.Y - position.Y;
            float desiredAngle = (float)Math.Atan2(y, x);
            return WrapAngle(desiredAngle);

        private static float WrapAngle(float radians)
            while (radians < -MathHelper.Pi)
                radians += MathHelper.TwoPi;
            while (radians > MathHelper.Pi)
                radians -= MathHelper.TwoPi;
            return radians;

I just don't understand it, can anyone think of a potential problem?

Jul 24, 2011 at 1:51 PM

Fixed this now i think. I simply set FixedRotation to true, I guess there was code going on in the background that was messing with the rotation, and i must have just dis-abled it. Went through a lot of hassle to find the answer to a simple problem. If you want to set the rotation of an object yourself then be sure to set the body's FixedRotation propperty to true.