Rotation before 0 and after 360
Hey everyone,
I'm trying to clamp my character rotation in the y rotation. At the moment when the min clamp is -10 (from the current character rotation) and max clamp is +10 (from the current character rotation) i'm unable to clamp it properly when it reaches less than 0 or more than 360. For example the character y rotation is 5 and as a result the min clamp won't clamp to 355 (it'll clamp to the max clamp to 15).
Vector3 eulerAngles = q.eulerAngles;
float minClamp = m_character.m_currentYRotation - 10;
float maxClamp = m_character.m_currentYRotation + 10;
eulerAngles.y = Mathf.Clamp(eulerAngles.y, minClamp, maxClamp);
return Quaternion.Euler(eulerAngles);
Not sure how to approach this and any help will be appreciated!
Comment
Your answer
Follow this Question
Related Questions
Euler angles clamping issue 0 Answers
Mathf.Clamp not working, and how to keep z to 0? 1 Answer
Clamp a 2D object controlled by the mouse 0 Answers
Smooth rotation problem 1 Answer