Hi there! I’m making a 2D top down game and I just started using CInemachine for the firs time.
I’m trying to get a smooth zoom effect working and I’m having issues.
So, right now I’m using the following code:
private void Update()
{
if (active)
{
float horizontalInput = Input.GetAxisRaw("Horizontal");
float verticalInput = Input.GetAxisRaw("Vertical");
direction.x = horizontalInput;
direction.y = verticalInput;
direction = direction.normalized;
velocity = direction * camSpeed * 15f;
movement = velocity * Time.deltaTime;
mapCam.transform.position = new Vector3(mapCam.transform.position.x + movement.x, mapCam.transform.position.y + movement.y, mapCam.transform.position.z);
float zoom = Input.mouseScrollDelta.y * zoomMagnitude;
mapCam.m_Lens.OrthographicSize = Mathf.Lerp(mapCam.m_Lens.OrthographicSize, mapCam.m_Lens.OrthographicSize + zoom, zoomSpeed * Time.deltaTime);
}
}
The zoom works (though it needs some major work) but it just snaps to the orthographic size and I wanted it to sort of smoothly transition. I have another virtual camera on the scene with a different orthographic size and when going from one camera to the other it zooms smoothly so I’m sure it can be done but I just can’t figure it out.
Not sure