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.

In unity I have a rigid body object and would like to apply force to a specific point. For example say I had a cube, I want to hit just the top right corner so it spins as a result. One idea I had considered is spawn a small sphere and fire it at it, then destroy the sphere. But is there a way to just apply the force?

share|improve this question
    
It's easier for us if you specify the engine in more than just the tag. And what have you tried? –  Almo Dec 19 '12 at 21:57
2  
The first words are the engine I'm using, and the ball thing was all I had tried, and for the record throwing a ball of considerable mass (like a cannon ball) at a ragdoll is incridbly fun –  ProtoJazz Dec 20 '12 at 2:40
    
Woops! Somehow I missed the "in unity" part. I just started at "I have a rigid body" for some reason! :) –  Almo Dec 20 '12 at 13:20
add comment

1 Answer 1

up vote 3 down vote accepted

http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForceAtPosition.html

void ApplyForce(Rigidbody body) {
    Vector3 direction = body.transform.position - transform.position;
    body.AddForceAtPosition(direction.normalized, transform.position);
}
share|improve this answer
    
I suppose that does answer it. I hadn't found that function. Now I just have to figure out how to get the vector 3 of the point I want to apply force to. I'm guessing the fps tutorial is my next step then –  ProtoJazz Dec 20 '12 at 2:41
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.