So I came across this script while reading a book about unity, and I have to say, it’s really confusing to me. I’ve spent the last day or so trying to understand it, but I wasn’t able to.
_rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
_rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert);
float delta = Input.GetAxis("Mouse X") * sensitivityHor;
float rotationY = transform.localEulerAngles.y + delta;
transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0);
I have two questions to ask about this, that the author didn’t really go into.
- Are the variables _rotationX and rotationY swapped? Because clearly they take the wrong axes from the mouse.
- Why are we decrementing the variable _rotationX? Is there a reason?
Every answer is welcomed
,