How to change the sensitivity on right click (when zoomed in)

I have acript to zoom in the camra but i want it to zoom in faster and change the sensitivity when zoomed in because it is to fast( because the cam has smaller field of view) if you can fix please tell me how!

Script:

private var baseFOV : float;

function Start () {
    baseFOV = Camera.main.fieldOfView;
}

function Update () {
         if (Input.GetMouseButton(1))
      Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,35,Time.deltaTime);
         else 
            Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,baseFOV,Time.deltaTime);
}

Using AOV instead of FOV might help!

public var minFOV : float = 1;
public var baseFOV : float = 0;
public var czoom : float = 0;

function Start ()
{
    baseFOV = Camera.main.fieldOfView;
}

function Update ()
{
	//Step one: Calculate the percentage of the maximum zoom that should be used (this is actually the perscentage of the maximum AOV (area of view)	
		if (Input.GetMouseButton(1))
			czoom = Mathf.Lerp(czoom, 0.0, Time.deltaTime);
		else 
			czoom = Mathf.Lerp(czoom, 1.0, Time.deltaTime);



	//Step two: Calculate the wanted Aov from our zoom percentage
		var maxAov : float = FOVtoAOV(baseFOV, Camera.main);
		var minAov : float = FOVtoAOV(minFOV, Camera.main);
		var aov : float = Mathf.Lerp(minAov, maxAov, czoom);
     
     
   	//Step three: Calculate the corresponding FOV for our wanted AOV
   		var fov : float = AOVtoFOV(aov, Camera.main);
   
   
   	//Step four: Apply the fov!
   	Camera.main.fieldOfView = fov;
}


function FOVtoAOV(fov : float, cam : Camera)
{
	return (fov/90.0) * cam.farClipPlane;
	//At 90 degrees the width of the AOV will be directly proportional to the distance of the camera
}

function AOVtoFOV(aov : float, cam : Camera)
{
	return (aov/cam.farClipPlane)*90.0;
	//When our AOV equals the farClipPlane, the FOV will be 90 degrees
}

Let me know how this works! :slight_smile: You may have to fine tune the speeds as it does zoom out rather quickly – but zoom speed slows down as you get to smaller zoom : D

I remember that this was my answer. :slight_smile:

Anyway try this, change the speed variable and enjoy :slight_smile:

private var baseFOV : float;
private var speed : float = 25f;

function Start () {
    baseFOV = Camera.main.fieldOfView;
}

function Update () {
         if (Input.GetMouseButton(1))
      		Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,35,Time.deltaTime*speed);
         else 
            Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView,baseFOV,Time.deltaTime*speed);
}