Hey I am building an MMO game and I have stuck in camera rotation on y-axis! i have successfully programmed the X-axis rotation but when I add the code of Y-axis rotation it starts interacting with Z-axis too and the rotation is a bit clamsy.
Here is my piece of code:
//Rotate the player left and right depending on the input of the X Axis of the mouse
transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X"), Time.deltaTime*1));
Quaternion zRotation = transform.rotation;
zRotation.z = 0.0f;
zRotation.x = 0.0f;
transform.rotation = zRotation;
//Rotate the camera up and down depending on the input of the Y axis movement of the mouse.
myCamera.transform.RotateAround(transform.position, Vector3.right, Input.GetAxis("Mouse Y"));
I am new in Unity3D and i can’t think of an other way doing this rotation! Thanks in advance!