I am trying to use the mouse scroll wheel to zoom my camera in, but when I tryed to scroll, the "Input.GetAxis" variable would change, but after I stopped scrolling it would reset back to zero, the camera zoom reseting with it. I do not know why this is happening, so any suggestions are welcome. Here is my script:
static var haveOverrided : boolean = false;
var sensitivityX : float = 15.0;
var sensitivityY : float = 15.0;
var minimumX : float = -360.0;
var maximumX : float = 360.0;
var minimumY : float = -60.0;
var maximumY : float = 45.0;
private var rotationY : float = 0.0;
private var rotationX : float = 0.0;
function Update () {
if (Input.GetButton ("Fire2")) {
haveOverrided = true;
rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
}
transform.localEulerAngles = Vector3(-rotationY, rotationX, 0);
mouseScroll = Input.GetAxis ("Mouse ScrollWheel");
var cameraZoom = Camera.main;
cameraZoom.camera.fieldOfView = mouseScroll*20+60;
print (mouseScroll);
}