Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to understand which is the right way to apply forces to a RigidBody.

I noticed that there are AddForce and AddRelativeForce methods, one applied in world space coordinate system meanwhile the other in the local space. The thing that I do not understand is the following: usually in physics library (es. Bullet) we can specify the force vector and also the force application point.

How can I do this in Unity? Is it possible to apply a force vector in a specific point relative to the given RigidBody coordinate system? Where does AddForce apply the force?

share|improve this question
    
Any force on a rigid body can also be represented as a force at center of mass plus a torque. I would hope there is a convenience method not to have to calculate that yourself, though. –  Kevin Reid Sep 12 '12 at 16:05
1  
@Kevin Reid: do you have any reference where is explained how can I perform this calculus? –  Heisenbug Sep 12 '12 at 16:16
add comment

1 Answer 1

up vote 4 down vote accepted

The documentation isn't terribly clear on it—and I'm not currently in a position to verify it—but I believe that the force applied from RigidBody.AddForce() (link) is applied at that object's root location (at its transform.position). If not at transform.position, then at the object's RigidBody.centerOfMass (link).

If you want to apply a force vector at a specific point, you probably want to use RigidBody.AddForceAtPosition() (link). Similarly, there is RigidBody.AddRelativeForce() (link) if you just want it local to the object itself.

And, for even more control if you know the torque you want to apply, there are RigidBody.AddTorque() (link) and RigidBody.AddRelativeTorque() (link).

</wallOfLinks>

share|improve this answer
1  
Yes thanks.. AddForceAtPosition is exactly what I was looking for. I didn't see it in the doc.. thanks for linking !! –  Heisenbug Sep 12 '12 at 20:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.