I have my script written out for my camera movement. I have "Pan" "Rotate" and "Zoom" functionality.
The problem is the rotation is really awkward. I need the rotation to be similar to an FPS. Zooming should only zoom so far or so close.
My questions are how can I refine my camera rotation and limit how close/far the camera can zoom?
Here is my script:
I'm guessing that my only problem is limiting how far the camera can zoom/rotate. Any help is appreciated.
asked Sep 03 '10 at 03:50 AM
You could Mathf.Clamp to limit the values to a range, or just ifcheck before applying change. Personally, I prefer clamping to be sure of the value range, but your setup would probably work better with ifchecks.
As an example:
Note that I combined both the zoom in and out into a single ifcheck, as the contents were identical. I then use an ifcheck to make sure that the 'z' position is between -20 and 0 (purely as examples, adapt to your own needs) before allowing the input to translate the position.
I'd also suggest that you changed the elseifs to 'if', otherwise you won't be able to zoom while either mouse button is held (unless that's intended functionality).
Regarding the camera rotation, the MouseLook script (from the standard assets) has a nice rotation setup. Might be worth taking a look at it, and seeing if it's similar to what you're after.