Add another zoom input?

I have a script in my game that zooms in the camera when you hold in the “Aim” input. Here it is…

var zoom : int = 30;          //determines amount of zoom capable. Larger number means further zoomed in
var normal : int = 60;        //determines the default view of the camera when not zoomed in
var smooth : float = 5;       //smooth determines speed of transition between zoomed in and default state
private var zoomedIn = false; //boolean that determines whether we are in zoomed in state or not

//This function toggles zoom capabilities with the Z key. If it's zoomed in, it will zoom out
function Update()
{
        zoomedIn = false;
    if( Input.GetButton("Aim"))
    {    
        zoomedIn = true;
    }
    
    //If "zoomedIn" is true, then it will not zoom in, but if it's false (not zoomed in) then it will zoom in.    
    if( zoomedIn == true )
    {  
        GetComponent.<Camera>().fieldOfView = Mathf.Lerp( GetComponent.<Camera>().fieldOfView, zoom, Time.deltaTime*smooth );
    }
    else
    {
        GetComponent.<Camera>().fieldOfView = Mathf.Lerp( GetComponent.<Camera>().fieldOfView, normal, Time.deltaTime*smooth );
    }
}

But I need help. I want to have something that toggles the zoom that you have in use. I know that sounds confusing but let me explain. I want it so if the input “Aim” is held and the input "Zoom is pressed then the field of view will change. But I still want the aiming function to work the same way. Let me say this really simply because I tend to over complicate everything. I want the FOV by default to be 60. If you hold “Aim” I want the FOV to be 30, but if while holding “Aim” you tap “Zoom”, then the FOV will change to 10. Thanks if you ca help!

You’ll need to keep track of whether they’re aiming and whether they’re zooming separately and then adjust accordingly
private vars aiming, zoomed = false
so if aiming {
-----if zoomed set fov to 10
----else set fog to 30
} else {
---- set fov to 60
}

Happy implementing :slight_smile: