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:
// This script controls camera movement.
//Variables
var horizontalSpeed = 0.5;
var verticalSpeed = 0.5;
var turnSpeed = 2;
function Update ()
{
//"Pan Camera"
if(Input.GetMouseButton(0))
{
var h = horizontalSpeed * -(Input.GetAxis ("Mouse X"));
var v = verticalSpeed * -(Input.GetAxis ("Mouse Y"));
transform.Translate (h, v, 0);
}
//"Rotate Camera"
else if(Input.GetMouseButton(1))
{
h = turnSpeed * Input.GetAxis ("Mouse X");
v = turnSpeed * Input.GetAxis ("Mouse Y");
transform.Rotate (v, h, 0);
}
//"Zoom Camera Out"
else if(Input.GetAxis("Mouse ScrollWheel") < 0)
{
var d = Input.GetAxis ("Mouse ScrollWheel") * 20;
transform.Translate (0, 0, d);
}
//"Zoom Camera In"
else if(Input.GetAxis("Mouse ScrollWheel") > 0)
{
d = Input.GetAxis ("Mouse ScrollWheel") * 20;
transform.Translate (0, 0, d);
}
else
{
}
}
I'm guessing that my only problem is limiting how far the camera can zoom/rotate. Any help is appreciated.