This might be hacky but I’m pretty stoked that I was able to get it working… even though it seems pretty easy.
Wanted to use the player controller but couldnt find mouse scroll in the options so just did it this way…
( I put an ortho size boundary of between 3 and 7 as you will see)
using UnityEngine;
using Cinemachine;
public class CameraZoom : MonoBehaviour
{
[SerializeField] CinemachineVirtualCamera virtualCamera;
float cameraDistance;
[SerializeField] float sensitivity = 10f;
void Update()
{
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
cameraDistance += Input.GetAxis("Mouse ScrollWheel") * sensitivity;
cameraDistance = cameraDistance < 3 ? 3 : cameraDistance;
cameraDistance = cameraDistance > 7 ? 7 : cameraDistance;
virtualCamera.m_Lens.OrthographicSize = cameraDistance;
}
}
}