- Home /
Conserving rotational momentum
So lets say I rotate my object on its y axis, If I then make it rotate on its x axis, it'll stop rotating on its y axis completely. How do I conserve the momentum?
Here's the script I'm using:
function FixedUpdate () { if (Input.GetKey("left")) { rigidbody.AddRelativeTorque (Vector3.up -10);
} if (Input.GetKey("up")) { rigidbody.AddRelativeTorque (Vector3.forward 10);
} }
Answer by kilgore · Sep 06, 2011 at 02:26 AM
Add Time.deltaTime to your equation like the following.
function FixedUpdate ()
{
if (Input.GetKey("left"))
{
rigidbody.AddRelativeTorque (Vector3.up * -10 * Time.deltaTime);
}
if (Input.GetKey("up"))
{
rigidbody.AddRelativeTorque (Vector3.forward * 10 * Time.deltaTime);
}
}
Your answer
Follow this Question
Related Questions
New to Unity: Trying to (loosely) simulate animal flight with separate buttons for each wing... 0 Answers
2d game - looking toward velocity for rigidbody player 1 Answer
Aligning 2 Quaternions Using Torque 1 Answer
Apply torque to align rigidbody to a specific angle in 3D 2 Answers
Torque towards Quaternion. 0 Answers