I’m trying to achieve a 3rd person camera which allows me to look up/down/left/right.
Here is my camera script:
look_x.transform.Rotate (_turnSensivity * -Input.GetAxis ("Mouse Y") * Time.deltaTime, _turnSensivity * Input.GetAxis ("Mouse X") * Time.deltaTime, 0);
I use it to lok up and down. Sadly, the Z rotation changes anyway and I end up with this:
The camera’a z rotation changes and there doesn’t seem to be a direct way to modify it. Here is what I tried:
look_x.transform.rotation = Quaternion.Euler(look_x.transform.rotation.x, look_x.transform.rotation.y, 0);
I tried to reset the Z rotation to zero, but then the camera doesn’t rotate at all. Both of these are located in the Update function like this:
void Update () {
look_x.transform.Rotate (_turnSensivity * -Input.GetAxis ("Mouse Y") * Time.deltaTime, _turnSensivity * Input.GetAxis ("Mouse X") * Time.deltaTime, 0);
look_x.transform.rotation = Quaternion.Euler (look_x.transform.rotation.x, look_x.transform.rotation.y, 0);
}
How do I undo the Z rotation, but allow the X and Y to be Rotated freely? Do I have to have 2 separate gameobjects for X and Y? If so, how do I get the camera to get the rotation from both?