title: Unity - Looking through the scope of a gun
body: <p>Right now I have 2 Cameras: the main camera displays the gun at its normal state and a second camera is attached to the gun (the gun is a child of the main camera) and when toggled it looks through the scope of the gun and increases the field of view.</p>
  
  <p>Heres a visual for a better understanding:</p>
  
  <p><a href="https://i.stack.imgur.com/GwIa2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GwIa2.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/qWBIo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qWBIo.png" alt="enter image description here"></a></p>
  
  <p>Now if I were to just toggle the second camera on and turn the main camera off, this would work splendid, but it's not very ideal. You should only have 1 camera per scene.</p>
  
  <p>So I want to Lerp the position of the camera to look through the scope and manually decrease the fieldofview. So I have written the following script:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[RequireComponent(typeof(Camera))]
  public class Zoom : MonoBehaviour {
  
      private Transform CameraTransform = null;
      public Transform ZoomedTransform;
  
      private bool zoomed = false;
  
      void Start () {
          CameraTransform = Camera.main.transform;
      }
  
      // Update is called once per frame
      void Update () {
          if (Input.GetKey (KeyCode.LeftShift)) 
          {
              CameraTransform.position = Vector3.Lerp (
                  CameraTransform.position, 
                  CameraTransform.position + ZoomedTransform.position, 
                  5f * Time.deltaTime
              );
              CameraTransform.Rotate(ZoomedTransform.rotation.eulerAngles);
          }
      }
  }
  </code></pre>
  
  <p>The problem with this is that it doesn't work: when I hit the zoom button, the camera speeds through the scene at the speed of light and it's hard to tell exactly what is going on.</p>
  
  <p>Could anyone give me some insight as to what I'm doing wrong? I think it is something to do with the parent-child relationship, but even when I've tried using static values, I cannot seem to replicate the correct solution.</p>
  
  <p>Hierarchy:</p>
  
  <p><a href="https://i.stack.imgur.com/SsHtA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SsHtA.png" alt="enter image description here"></a></p>