I’m using the function Rigidbody.MoveRotation in my script to rotate a cube. In the inspector, the rotation appears to go from 180° to -180°.
I want to write a simple script to find out how fast the cube is rotating. At first I wrote a simple:
Mathf.Abs(current_angle - previous_angle)
where the previous angles is the rotation angle from the previous fixedupdate. This does not always work though, since when the previous_angle is, say 170, and a rotation of 20 degrees happens, the current_angle becomes -170.
Is there a simple way to fix this? Right now I’m using an IF to check whether or not the two angles are near 180°, and I’m using a custom calculation for that case, but if the rotation speed is high, this could not work either.