0 Replies - 194 Views - Last Post: 02 April 2021 - 09:55 AM Rate Topic: -----

#1 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 244
  • Joined: 24-February 15

Forward scrolling leads to zooming out

Posted 02 April 2021 - 09:55 AM

I try to implement this function, where I can use the camera to zoom in and out into the object. But when I scroll forward I also zoom out. Does someone know what could be the issue?


 // Control the distance between the object && camera
    private void ZoomIntoObject(float maxZoom, float minZoom)
    {     
        float inputValue = Input.GetAxis("Mouse ScrollWheel");
 
        // While scrollwheel
        if (inputValue != 0f)
        {
            zPos += inputValue * movSpeed;
            zPos = Mathf.Clamp(zPos, minZoom, maxZoom);
 
            // Move forward on the z-as && Clamp maxZoom
            transform.position += transform.forward * zPos;
        }

        Debug.Log(inputValue);
    }



Is This A Good Question/Topic? 0
  • +

Page 1 of 1