Question by
Duncster94 · Jul 13, 2016 at 01:16 AM ·
zoom
Clamping camera forward and backward vector
My perspective camera is rotated on the x axis. I've implemented a zoom with the scroll wheel and it works great.
I'm trying to limit the zoom, however. My solution right now is to take the relative scale of the transform.forward
y and z components and clamp the y and z position of the camera with those. It works well, except it limits the y axis, so when I move around I can't go below a given y due to my clamp with is ideally meant to affect the zoom only.
Is there a way to clamp the forward and backward movement of the camera? I've been looking everywhere but can't find a thing.
Thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612084723im_/https://answers.unity.com/themes/thub/images/avi.jpg)