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

Providing impulse and angular velocity

Topics: Developer Forum
Dec 26, 2010 at 8:07 PM
Edited Dec 26, 2010 at 11:50 PM

Hey. I'm working on a pool-esque game and am going to be using Farseer. I'm new to the engine, but have a quick question. How do I provide an impulse (from the code behind) at a particular location on an object? (e.g. cue stick hitting cue ball in a particular area). Also, what settings should be looking at in order to ensure that the cue ball receives angular velocity and 'curves' properly? I'm not great at physics and get confused between Moment of Inertia, Torque etc... :( Thanks for any help.

Dec 26, 2010 at 10:05 PM


i'm not a farseer expert but i think i can give you some answer :

when you apply a force or an impulse using the ApplyLinearImpulse and ApplyForce method of the body object, you can specify a point to tell farseer where he has to apply the force/impulse on the targeted body.

To apply angular velocity you can use the ApplyAngularImpulse method of the body.

The Moment of inertia is a measure of an object's resistance to changes its rotation, in other word  greater is this value harder it is to make it rotate.

Torque is like a force that rotate an object on an axis, it can be thought of as a twist.

You should watch the Sample code and play with it, it could be helpfull ;)

Dec 26, 2010 at 11:53 PM

Hey mog, thanks for the reply. I was using the PhysicsHelper library and couldn't see anything to do with impulses (just force). I'll take a look at those methods and see how to get it integrated with the PH library.

Dec 27, 2010 at 6:13 PM

I'm using this:

ApplyLinearImpulse(new Vector2(0f, 100f), new Vector2(0,0));

and although it works, the second parameter doesn't seem to make any difference. I've tried different values, but the particle always jumps in the same direction (from rest). What should the second parameter represent?


Dec 27, 2010 at 10:33 PM

If your shape is a circle, then the second parameter will apply torque to the circle. The first parameter is both the direction and magnitude of the impulse. The second one is the local coordinates on the circle where you apply the impulse. In your case, the first parameter should contain the angle the cue has to the center of the circle. The second parameter should be the point of impact on the ball.

Dec 28, 2010 at 12:34 AM

Thanks for clearing that up, Genbox.