|
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.
(comments are locked)
|
|
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. unfortunately the mouselook script is in C# and I really wanted everything to be in JavaScript, but I suppose it shouldn't be to hard to convert. I'll give it a shot. Thanks a lot for all your help.
Sep 03 '10 at 01:26 PM
Josh 7
(comments are locked)
|

I'm assuming that the camera script is attached to some sort of player object, and the zoom in/out is setting the relative position of the camera to that object..?