So I have been working on my Camera Controller and I have been having trouble implementing a zoom limit on the camera because the z position move as the y position moves to zoom in. I got it once but the camera started zooming in a weird way.
-Any help is appreciated =)
private Vector3 _newZoom;
[SerializeField]
private Vector3 _zoomAmount;
[SerializeField]
private float _zoomMaxY = 55f;
[SerializeField]
private float _zoomMinY = 25f;
[SerializeField]
private float _zoomTime = 1f;
void Update()
{
HandleKeyboardInput();
HandleMouseInput();
}
private void Awake()
{
_newZoom = _cameraTransform.localPosition;
}
if (Input.GetKey(KeyCode.PageUp))
{
_newZoom += _zoomAmount;
}
if (Input.GetKey(KeyCode.PageDown))
{
_newZoom -= _zoomAmount;
}
_cameraTransform.localPosition = Vector3.Lerp(_cameraTransform.localPosition, _newZoom, Time.deltaTime * _zoomTime);