title: Unity: Scroll to "zoom" to point
body: <p><strong>My app (using Unity 2017.3.1f1) is set up like this:</strong></p>
  
  <ul>
  <li>The perspective camera is inside the "player" object (collisions are disabled) and also a child of it (to get a 1st person view)</li>
  <li>The camera has a "MouseLook" script (I changed a few things in Unity's default one) that keeps the cursor locked and hidden in the middle of the screen (<code>Cursor.lockState = CursorLockMode.Locked</code> &amp; <code>Cursor.visible = false</code>)</li>
  <li>The "player" has a general "input" script and a movement script: If wasd are pressed, these key presses move the player object, which also makes the camera move</li>
  </ul>
  
  <p><strong>What I want to achieve:</strong></p>
  
  <ul>
  <li>Use the scroll wheel on the mouse to move towards the point the camera is looking at or away from it, independent if there's an object.</li>
  <li>I do NOT want to change the FOV/scale</li>
  <li>It's not necessary to use <code>Lerp</code>, I just want to move the player a step towards the target position every frame the mouse wheel is used</li>
  </ul>
  
  <p><strong>What I've tried:</strong></p>
  
  <p><em>1a. In the general input script:</em></p>
  
  <pre><code>if(Input.GetAxis("Mouse ScrollWheel") != 0) {
      transform.Translate(0,0,Input.GetAxis("Mouse ScrollWheel") * 200);
  }
  </code></pre>
  
  <p><em>1b: In the general input script:</em></p>
  
  <pre><code>if(Input.GetAxis("Mouse ScrollWheel") != 0) {
      transform.position += transform.forward * Input.GetAxis("Mouse ScrollWheel") * 200;
  }
  </code></pre>
  
  <p>Both work the same but only move the player/camera on the same y level, even when looking down/up. <code>transform.up</code> always outputs "(0.0, 1.0, 0.0)", so there's no point incorporating that.</p>
  
  <p><em>2.A new script on the camera (<a href="https://stackoverflow.com/a/33434343/2016165">source</a>):</em></p>
  
  <pre><code>public class ScrollToZoom : MonoBehaviour {
      public GameObject player;
  
      void Update () {
          if(Input.GetAxis("Mouse ScrollWheel") != 0) {
              RaycastHit hit;
              Ray ray = this.transform.GetComponent&lt;Camera&gt;().ScreenPointToRay(Input.mousePosition);
              Vector3 desiredPosition;
  
              if(Physics.Raycast(ray,out hit)) {
                  desiredPosition = hit.point;
              } else {
                  desiredPosition = transform.position;
              }
              float distance = Vector3.Distance(desiredPosition,transform.position);
              Vector3 direction = Vector3.Normalize(desiredPosition - transform.position) * (distance * Input.GetAxis("Mouse ScrollWheel"));
  
              transform.position += direction;
          }
      }
  }
  </code></pre>
  
  <p>This doesn't work at all because "direction" is always (0,0,0) because the mouse cursor is locked (which I can't/won't change).</p>
  
  <p>How do you incorporate the rotation around the x-axis (I clamp it to +/- 90° in the "MouseLook" script) in this?</p>