Rotate rigidbody to target (physically correct)

I know this has been asked before, but I couldn’t find a real answer.

I want to smoothly rotate a rigidbody to a specific target rotation, but it has to be using the physics engine because it will collide with other rigidbodies. I can’t use simulated physics because they ignore other objects, which would result in really strange behavior.

I hope there is a relatively easy way to do this…

[Disclaimer: I’ve used this trick, but not in Unity]

Taking the (Vector3) dot product of your forward and the target’s forward will give the rotation axis (or use whichever axis you want to line up.) It tells you if you want to spin along y, or x, or some odd diagonal. Then rigidbody.AddTorque(axisYouFound)` should push you along that axis.

Quaternion.Angle between your two rotations gives the angle along that same axis, which you can use for a speed. The “axis” in rb.addTorque is really an axis and speed. In the example from the docs, (0,10,0) spins you like a top, but 10 times faster than (0,1,0).
So, in addTorque, axisYouFound*Angle*scaleFactor should allow you to set a speed.

Now, if your z-rotation isn’t lined up (the “roll”) – I think the same trick can handle it, comparing ups in the final position.