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


Topics: User Forum
Aug 4, 2011 at 4:55 PM
Edited Aug 4, 2011 at 5:07 PM


I've big problems with getting the gravity working. 
I've created a body for my Player with this code:



myBody = BodyFactory.CreateRectangle(world, Size.X, Size.Y, 1);
myBody.BodyType = BodyType.Dynamic;
myBody.Mass = 1;
myBody.Inertia = myBody.Mass * (Size.X * Size.X + Size.Y * Size.Y) / 12;
I also set the gravity for my World object:
World world = new World(new Vector2(0,25));
And updated it:

            world.Step(Math.Min((float)gameTime.ElapsedGameTime.TotalSeconds, (1f / 60f)));

The Player doesn't move. What am I doing wrong?!

Thanks for your time.

Aug 4, 2011 at 5:41 PM

You should be calling world.Update to start the physics simulation.

Aug 4, 2011 at 7:49 PM

Oh, now it works... Crazy.