5
\$\begingroup\$

I'm new to Farseer and have a simple question. The demos I went through didn't seem to demonstrate what I want. I would like to apply an impulse (not force) to an object at a specific position on that object. How would I go about doing this in code? (I've created the objects already). I'll be using XNA and SL, but I guess the code for this method would be the same. thanks

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

I haven't used it, but a quick google search turned up this thread.

Here is a summary:

When you apply a impulse or force using ApplyLinearImpulse or ApplyForce respectively, you can specify a point indicating where to apply the impulse or force on the target.

To apply angular velocity, use ApplyAngularImpulse.

The moment of inertia can be considered as an object's resistance to changes in its rotation; the greater the moment of inertia is, the 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.

Consider a game of pool / billiards using:

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

The first parameter is the direction and magnitude of the impulse. Since the shape is a circle, the second parameter will apply torque. Specifically, it is the local coordinates on the circle where you apply the impulse. Thus, 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.The first parameter is both

It makes sense since all physics engines, in my experience, give you the ability to apply impulses and/or forces. So look for the ApplyLinearImpulse/ApplyAngularImpulse functions. They enable you to specify points where you apply the impulse.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, I didn't see that when I searched, but looks like what I need :) \$\endgroup\$
    – Skoder
    Dec 27, 2010 at 15:41
0
\$\begingroup\$

You want to use the Body.ApplyLinearImpulse, or you can directly set the Body.LinearVelocity.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .