In my game it should be possible to rotate the character 180 degrees. I always want the character to rotate clockwise.
If the character is rotated 0 degrees and I press the rotate button, the character rotates clockwise to 180 degrees. However, if I know press the rotate button again, the character rotates to 0 degrees but doing so counterclockwise. How can I modify my code so that the character always rotates in a consistent direction?
One solution I've been thinking of is to do the rotaiton in steps like on first button press { 90, 180 } and on second {270, 0 }...
Any help would be greatly appreciated!
_currentTurnAroundAngle += TurnAroundSpeed*Time.deltaTime;
transform.rotation = Quaternion.Euler(0, Mathf.Lerp(transform.rotation.eulerAngles.y, _targetTurnAround, _currentTurnAroundAngle), 0);
if (transform.rotation.eulerAngles.y >= (_targetTurnAround - 0.1f) && transform.rotation.eulerAngles.y <= (_targetTurnAround + 0.1f))
{
_currentTurnAroundAngle = 0;
transform.rotation = Quaternion.Euler(0, _targetTurnAround, 0);
_targetTurnAround = (_targetTurnAround == 0 ? 180 : 0);
_isTurning = false;
}