- Home /
Question by
_-puppytails-_ · May 11, 2020 at 12:08 AM ·
mathmathf.clamp
Mathf.Clamp not functioning
i see nothing wrong with the code. What is at fault?
float rotateY = 0; rotateY += -Input.GetAxis("Mouse Y") s.XSens Time.deltaTime; rotateY = Mathf.Clamp(rotateY, -90, 90); transform.eulerAngles += new Vector3(rotateY, 0, 0);
Comment
Best Answer
Answer by Bunny83 · May 11, 2020 at 12:24 AM
You probably wanted to do
transform.eulerAngles = new Vector3(rotateY, 0, 0);
instead of
transform.eulerAngles += new Vector3(rotateY, 0, 0);
Otherwise your Mathf.Clamp call will only limit the rate of change and hot the absolute angle, if that's actually what you wanted to do. You haven't mentioned what you want to do so we can not tell if your code is wrong.