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

How to increase acceleration by gravity?

Topics: Developer Forum, User Forum
Feb 21, 2012 at 4:41 PM

Hi i'm using Farseer physics for my platformer,

and the objects in the world are moving very slow although i set the gravity to (0, 10000000).

Any idea how i can let them move faster?



Feb 21, 2012 at 5:25 PM

I had this same problem when I first started using Farseer. The problem is that your values need to be converted into 'meters' in world space. For example, take a look at the code I use to create my player character, seen below. I use GLEED2D to load my levels and initial position of the player in that level:


        public void LoadPlayerCharacter()
            RectangleItem rectItem;
            CircleItem circleItem;

            //Load GLEED2D Player layer
            Layer layer = level.getLayerByName("Player");

            //Create the upper collidable portion of the player
            rectItem = layer.Items[0] as RectangleItem;
            rectItem.Position.X = rectItem.Position.X.ConvertToWorldUnits() + ((rectItem.Width.ConvertToWorldUnits()) / 2);
            rectItem.Position.Y = rectItem.Position.Y.ConvertToWorldUnits() + ((rectItem.Height.ConvertToWorldUnits()) / 2);

            upperBody = BodyFactory.CreateRectangle(world, rectItem.Width.ConvertToWorldUnits(),
                        rectItem.Height.ConvertToWorldUnits(), 1f, rectItem.Position);
            upperBody.BodyType = BodyType.Dynamic;
            upperBody.Friction = 5f;
            upperBody.Restitution = 0.0f;
            upperBody.FixedRotation = true;
            upperBody.CollidesWith = Category.Cat1;

            //Create the lower collidable portion of the player
            circleItem = layer.Items[1] as CircleItem;
            circleItem.Position.X = circleItem.Position.X.ConvertToWorldUnits();
            circleItem.Position.Y = circleItem.Position.Y.ConvertToWorldUnits();

            lowerBody = BodyFactory.CreateCircle(world, circleItem.Radius.ConvertToWorldUnits(), 1f, circleItem.Position);
            lowerBody.BodyType = BodyType.Dynamic;
            lowerBody.Restitution = 0.0f;
            lowerBody.Friction = 5f;
            lowerBody.CollidesWith = Category.Cat2;
            lowerBody.CollisionCategories = Category.Cat2;

            //Attach revolute joint to upper and lower bodies
            playerMotor = JointFactory.CreateRevoluteJoint(world, upperBody, lowerBody, Vector2.Zero);
            playerMotor.MaxMotorTorque = 10f;
            playerMotor.MotorEnabled = true;



Everywhere you see ".ConvertToWorldUnits()", I am taking that value and dividing it by 64f, which signifies one meter in the world space.

rectItem.Position.Y.ConvertToWorldUnits() == rectItem.Position.Y / 64f

Check out the HelloWorld example in the download section here. It shows you the basic way you should set up the camera and values to correctly use the Farseer Engine.

Here is the link to the download: