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

Acceleration due to gravity not being applied

Topics: Developer Forum
Apr 4, 2011 at 5:53 PM

Hey Everyone,

  I am new to the Farseer code and I am attempting to make C# forms application using the Farseer library.  I have created a form, placed a floor on the screen and I am dropping a single rect from the top of the form.  The block appears to fall BUT it does not accelerate with the gravity.  I am sure it is something I am not setting, but for the life of me I cant figure it out and was hoping someone might point me in the right direction.  Here is the meat of the code:

Thanks in advance for the help,



 World world = new World(new Vector2(0.0f, 0.1f));

Body floor = BodyFactory.CreateRectangle(world, 10000.0f, 30.0f, 100, new Vector2(0.0f, Height));
floor.BodyType = BodyType.Static;

// Block
  Body Block1 = BodyFactory.CreateRectangle(world, 100.0f, 10.0f, 100, new Vector2(Width/2, 0));
 Block1.BodyType = BodyType.Dynamic;

(The step here is called when I timer goes off every .01/second)
 //Step the world a 10th of a second.


(I draw the object this way)

 gr.TranslateTransform(body.Position.X, body.Position.Y);
 gr.RotateTransform((float)((body.Rotation *360)/(2*Math.PI)));
 gr.FillRectangle(SystemBrushes.ButtonFace, -size.Width / 2.0f, -size.Height / 2.0f, size.Width, size.Height);  

Apr 4, 2011 at 8:05 PM

Ok, stupid me, I did not look far enough in the forums for the answer, the problem was that I was using Pixel and NOT Meters.  Once I converted, you can see the gravity fine!  Sorry about the noise.