world.Step function not updating body position

Topics: Developer Forum, User Forum
Aug 13, 2011 at 2:10 PM

During debugging, I encountered a bug where the position of a dynamic body doesn't get updated after the 2nd call of world.Step.  I create a body at position (0, 0) with a velocity of (1, 1) and let it run for 3 time units.  The ending position should be (3, 3), but it is (2, 2).  Here's a simple example to demonstrate what I mean.  Any ideas of why this is happening would be appreciated.  Thanks.

        public void TestWorldStep1()
        {
            //Create a dynamic body at position (0, 0) with velocity (1, 1) and run it for 3 steps.
            //Ending position should be (3, 3).
            World world = new World(Vector2.Zero);
            Body body = FarseerPhysics.Factories.BodyFactory.CreateCircle(world, 1, 1);
            body.BodyType = BodyType.Dynamic;
            body.Position = new Vector2(0, 0);
            body.LinearVelocity = new Vector2(1, 1);

            world.Step(1);  //body position gets updated to (1, 1).
            world.Step(1);  //body position doesn't get updated and is still (1, 1).
            world.Step(1);  //body position gets updated to (2, 2).

            System.Console.WriteLine("Position: " + body.Position);
        }