Question by
a7mad20031 · May 18, 2018 at 03:39 PM ·
c#cameratransformcamera rotatebegginer
why the camera rotate in the z axis
I made this script to let the player move the camera while holding the left mouse button but after awhile both game objects (the game object and the camera) start to slightly rotate in the "z"
cam is the camera gameobject which is a child of this gameobject
public float rotSpeed = 1f;
void Update() {
if (Input.GetMouseButton(1))
{
cam.transform.Rotate(Vector3.right, Input.GetAxis("Mouse Y") * rotSpeed);
transform.Rotate(Vector3.up, Input.GetAxis("Mouse X") * rotSpeed);
}
}
Comment
I actually copied your code into an empty scene and I'm getting no rotation on z on either the parent or the camera. Can you give some more info about the objects you are using?