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

Why slow movement?

Topics: Developer Forum, User Forum
Jul 27, 2011 at 12:14 PM
Edited Jul 27, 2011 at 12:20 PM

Hello! I'll try to explain my trouble, my english is very poor. I'm doing a game in WP7 using Farseer physics, it's a basketball game. My trouble is that the move of the ball is very slow when the gravity act in it.

I have a world created like this:

world = new World(new Vector2(0f, 20f));

And then, in update method:

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

I've the ball created like this:

body = BodyFactory.CreateCircle(world, 17, 1f);
body.CreateFixture(new PolygonShape(PolygonTools.CreateCircle(17, 10), 1f)); 
body.BodyType = BodyType.Dynamic;
body.Restitution = 0.8f;

And then, when I want to throw the ball I do:

body.ApplyForce(new Vector2(100000000000, -100000000000));

Why the ball is very very slow movement?

Only I do the ApplyForce once time when I want to throw the ball, is correct? Or I'va to ApplyForce in loop update?

And if I don't applyForce for that only act the gravity, it's the same that I put 20f that 2000f to the vector gravity, the ball down at the same velocity.


Thanks for all!

body.ApplyForce(new Vector2(100000000000, -100000000000));
Jul 27, 2011 at 6:22 PM

hey man


Iam new here :)


I think your problem in World.Step()


the argument I have in C# is


world.Step((float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f );

converting the number returned from  TotalMilliseconds to seconds :)

Jul 28, 2011 at 7:12 AM

I don't think you need to create a new fixture for the body, BodyFactory already does this for you.

The slow movement may be down to the scale of things. You have created a ball with a 17 meter radius... that's a pretty big ball to be throwing.

Take a look at the samples and use the ConvertUnits.ToSimUnits() method maybe?

Jul 28, 2011 at 6:55 PM

It's perfect gjwebber. Now work perfectly.

I have another cuestion.

How can I calculate the Vector2 to the ApplyLinearImpulse if I have the power and the angle?

Jul 30, 2011 at 4:24 AM

This should work.

Vector2 i =  Vector2(cos(angle), sin(angle)) * power;