Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I just want to know how to use rigitbody2d.AddTorque() and an example script would be great :D. I am trying to rotate a cube forever using it as a test.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Make sure that "Is Kinematic" option for rigidbody in the inspector is off.

Here is a very basic example for adding torque.

var torque: float;
var rigidBody: Rigidbody2D;

function Start() {
    torque = 20;
    rigidBody = GetComponent.<Rigidbody2D>();
}


function FixedUpdate() 
{
    rigidBody.AddTorque(Time.deltaTime*torque);
}

Time.delta time is just to make it device independent.

Hope this resolves your doubts :)

share|improve this answer

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.