Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
790 B
7
Indexable
Never
    void Update()
    {
        float scroll = Input.GetAxis("Mouse ScrollWheel");

        if (scroll != 0 && isZoomUnlocked)
        {
            if (scroll > 0)
            {
                ZoomIn();
            }
            else
            {
                ZoomOut();
            }
        }
    }

    private void ZoomIn()
    {
        if (virtualCamera.m_Lens.FieldOfView > minZoomFOV)
        {
            virtualCamera.m_Lens.FieldOfView -= zoomSpeed;

            virtualCamera.Follow = transform;
        }
    }

    private void ZoomOut()
    {
        if (virtualCamera.m_Lens.FieldOfView < maxZoomFOV)
        {
            virtualCamera.m_Lens.FieldOfView += zoomSpeed;

            virtualCamera.Follow = transform;
        }
    }
Leave a Comment