Here is my C# script for camera rotation:
public void CameraRotate(Camera InputCamera, float InputRotationSpeed)
{
if (Input.GetButton("Rotate Camera") == true)
{
float MouseXMovement;
float MouseYMovement;
MouseXMovement = Input.GetAxis("UnityDefaultMouseX");
MouseYMovement = Input.GetAxis("UnityDefaultMouseY");
InputCamera.transform.Rotate(-MouseYMovement * InputRotationSpeed, MouseXMovement * InputRotationSpeed, 0);
}
}
But if I move cursor diagonally, or make circles with it, the camera also turns around Z axis, despite the fact that Z-rotation is set to zero. How I can avoid that?
Sorry for bad english. I hope you’ll understand me.