title: Unity - How to zoom in and out with camera movement?
body: <p>I'm working on a project with an indie studio and I was asked to make a change to the way the camera works
  so when the player is looking up, the camera zoom in, and when the player is looking down the camera zoom out.</p>
  
  <p>My solution works, but it's too snappy. The camera will zoom but in an instant. I've tried adding more larping or smoothing but it didn't helped. I'm sure there's more elegant way to do it.
  Glad if anyone can help.</p>
  
  <pre><code>float currentPitch = Values.pitch;
      if(currentPitch &gt; lastFramPitch){
          Values.runTimeDistanceFromTarget.z += Values.zoomSensitivity;
          Values.runTimeDistanceFromTarget.z = Mathf.Lerp(Values.runTimeDistanceFromTarget.z , Values.zoomIn , Values.zoomSensitivity);
      }
      else{
                      Values.runTimeDistanceFromTarget.z -= Values.zoomSensitivity;
          Values.runTimeDistanceFromTarget.z = Mathf.Lerp(Values.runTimeDistanceFromTarget.z , Values.zoomOut , Values.zoomSensitivity);
      }
  
      lastFramPitch = currentPitch ; 
  </code></pre>