Hey. I am using angularVelocity to make a rigidbody rotate. So , sometimes it’s easier to rotate to the target rotation clockwise , sometimes counterclockwise. Why doesn’t this work?
if(targetRotation.eulerAngles.y<transform.eulerAngles.y){
rigidbody.angularVelocity = new Vector3(0,3,0);
}else{
rigidbody.angularVelocity = new Vector3(0,-3,0);
}
if(targetRotation==transform.rotation){
rigidbody.angularVelocity = new Vector3(0,0,0);
}
But I need it done with angularVelocity because I am performing some physics calculations
– byteprogrammingI think Mathf.DeltaAngle should work then. I've not used it, but it sounds like it should give you a positive or negative value that's the shortest number of degrees to move to get to the target angle.
– Dave-Carlile