RotateAround wont rotate to starting position
So what I am trying to do is rotate a game object by 90° to the right. It works great except when rotating from 90° to 0°.
It rotates smoothly everywhere but the last spin in the sequence. If I don't have the check to see if it is moving under RotateRight then I can get it to skip the zero rotation and go back to 270° rotating like it should from 90° to 270°.
Any ideas why it won't rotate the last jump?
newAngle = 0;
void Update () {
if (spinRight) {
Vector3 spinTo = new Vector3 (0, 0, newAngle);
if (Vector3.Distance (board.GetComponent<Transform> ().eulerAngles, spinTo) > 1f) {
board.GetComponent<Transform>().RotateAround(board.GetComponent<Transform> ().position, spinTo, -100 * Time.deltaTime);
} else {
board.GetComponent<Transform> ().eulerAngles = spinTo;
spinRight = false;
}
}
}
public void RotateRight() {
//if (!spinRight) {
newAngle = newAngle - 90;
if (newAngle < 0) {
newAngle += 360;
} else if (newAngle > 360) {
newAngle -= 360;
}
spinRight = true;
/}
}
Comment