I’m using ‘Mathf.MoveTowardsAngle()’ to rotate an object towards an angle(zero). Sometimes it works as expected and other times it sets the rotation to a value close to zero(but not zero). I’m assuming this is because I’m using eulerAngles but input on why this is happening would be much appreciated. Here’s a snippet of my code:
/*targetRotation = 0*/
float angle = Mathf.MoveTowardsAngle(myTransform.eulerAngles.z, targetRotation, moveSpeed * Time.deltaTime);
myTransform.eulerAngles = new Vector3(myTransform.eulerAngles.x, myTransform.eulerAngles.y, angle);
if (targetRotation == myTransform.eulerAngles.z)
{
//Do Something(In my code, it just changes a enum value)
}
Also I should note that this formula is placed in update and the rgidbody2D.fixedAngle of the object is set to true before running this(I set it true in order to negate the effects of physics on its rotation when it’s moving towards the angle).