ApplyForce() issue

Topics: Developer Forum, User Forum
Apr 29, 2012 at 10:40 AM

Hi,

I started to play around with Farseer recently (great work by the way!).

I have an issue when using ApplyForce() function on my bodys, that just simply doesn't work.

This is how I initialize my vars :

 

Body circleBody;
Fixture fixture;
CircleShape shape;
World physicWorld;

physicWorld = new World(new Vector2(0, 100));
circleBody = new Body(physicWorld);
circleBody.BodyType = BodyType.Dynamic;
shape = new CircleShape(60, 20);
fixture = circleBody.CreateFixture(shape);

 

And when doing a simple :

 

fixture.Body.ApplyForce(new Vector2(1000f, 0));

Anything is happening.

I tried with Explosion class, no effect either ...

Am i missing something ?

Thanks

Apr 29, 2012 at 12:52 PM

Your circle has 20 density and has a 60m raidus (120m diameter).  This is roughly the volume of the largest cruise ship (Oasis of the Seas?). You are then trying to move it with 1kN force. This is what - the typical force a weight-lifter uses for bench-pressings? You can see how such force will produce negligible acceleration on a parked cruise-ship...

You should scale down your objects. Density of 1 by the convention used in the engine is the typical density of a rigid body (think rock). The meter scale that works best for the solver is 0.1-10m. Scale the forces accordingly.

Apr 30, 2012 at 10:50 AM

Thanks for the reply. With a 1 density i can move it.

But i can't downscale my shape, the image is a ball 120x120px, so radius = 60.

I need to keep that value for the collisions, anyway to get the objet more "light" without changing this value ?

 

Thanks

Apr 30, 2012 at 3:36 PM

You can use a unit converter for scaling (it is actually essential you do so). When you set up the physics convert the pixels to meters with some arbitrary ratio that would put the shapes into the 0.1-10m range. Then when your graphics code needs to read the body's position or vertices convert back with the inverse ratio.

See the ConvertUnits class if Farseer's Samples (Samples XNA/ScreenSystem/ConverUnits.cs)

Post by the creator of box2d:

http://box2d.org/2011/12/pixels/

Apr 30, 2012 at 6:08 PM

Thanks a lot man ! :)