Using Torque to kill Angular Velocity

I’m trying to write a method that adds a limited amount of torque to a rigidbody in order to slow its rotation. I tried to do it in a way that, apart from limiting the actual force to a lower value, basically amounted to the following:

rigidbody.AddRelativeTorque(-rigidbody.angularVelocity);

It was meant to be applied over multiple FixedUpdate() cycles until the angular velocity was completely cancelled. But of course, nothing goes as planned, and instead I just have rigidbodies rotating around their z axes a lot. There is no drag and no other forces affecting it, mind you.

Now, I tried converting the angularVelocity from radians to degrees, I tried AddRelativeTorque and AddTorque, and I also tried plenty of modifications to the exact amount of force applied - to no avail.

My instincts tell me that getting the angularVelocity vector, multiplying it with (-1) and applying that as force should slow rotation and cancel it eventually (the time needed depending on the objects mass)…but it doesn’t work that way.

Any ideas, gentlemen?

Untested, but I’m pretty sure this will work. It should be done in FixedUpdate(), and the slowdown will not be linear. You may need to fiddle with the constant.

rigidbody.angularVelocity *= 0.985;

Depending on how you want to motion to slow, you can use Lerp() or MoveTowards, or others to scale the components of angularVelocity to 0 over time. Based on your question, I’m think you already realize you could play with the ‘angularDrag’ setting…upping it to get the object to slow then returning it to some value after the angularVelocity falls below some threshold.

Vector3 rotation = transform.InverseTransformDirection(rb.angularVelocity);

 if (rotation.y <= .1 && rotation.y >= -0.1)
            {
                rotation.y = 0;
                Debug.Log("cancel y");
            }
else if (rotation.y > .1)
            {
                rb.AddRelativeTorque(Vector3.up * yaw * -1);
            }
else if (rotation.y < -0.1)
            {
                rb.AddRelativeTorque(Vector3.up * yaw);
            }
rb.angularVelocity = transform.TransformVector(rotation);

I know this is a fairly old question, but it took me a bit to solve a similar question.
I cut the sections for X and Z, but they work the same as Y. This code was part of a greater fragment that allowed me to selectively damped various axis of a spaceships rotation.
The “if (rotation.y <= .1 && rotation.y >= -0.1)” section is because this code would otherwise vibrate as the thrust would push rotation from one direction to the other every frame.