Hello i am working on a game where you have to be able to zoom by clicking the middle mouse button. I have created a script, however when i start the game it instantly zooms in and i cant zoom out
here is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Zoom : MonoBehaviour
{
public int zoom = 20;
public int normal = 60;
public float smooth = 5;
public Camera cam;
private bool isZoomed = false;
void Update()
{
if (Input.GetMouseButtonDown(1))
{
isZoomed = true;
}
if (isZoomed == true)
{
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, zoom, Time.deltaTime * smooth);
}
else
{
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, zoom, Time.deltaTime * smooth);
}
}
}