I have an RTS style top-down / isometric view control scheme that I am attempting to work on.
So far I have WASD and Keypad controlling movement going Left, Right, Forward, and Backwards.
I am attempting to add a “Zoom” function to “Mouse Scrollwheel” that effects the FOV of the camera. The code I have SHOULD work, yet it’s not doing anything. And yes, I have tested, my Mouse Wheel works just fine.
Here is my code (including Keyboard Movement):
// Camera Scroll Speed
var scrollSpeed : float = 20.0;
function Update () {
var fwdBack : float = Input.GetAxis ("Vertical") * scrollSpeed;
var leftRight : float = Input.GetAxis ("Horizontal") * scrollSpeed;
fwdBack *= Time.deltaTime;
leftRight *= Time.deltaTime;
transform.Translate (leftRight, 0, 0);
transform.Translate (0, 0, fwdBack);
// Mouse Scroll Wheel Zoom
//------------------Code for Zooming Out------------
if (Input.GetAxix("Mouse ScrollWheel") <0)
{
if (Camera.main.fieldOfView<=100) {
Camera.main.fieldOfView +=2; }
if (Camera.main.orthographicSize<=20) {
Camera.main.orthographicSize +=0.5; }
}
//----------------Code for Zooming In-----------------------
if (Input.GetAxis("Mouse ScrollWheel") > 0)
{
if (Camera.main.fieldOfView>2) {
Camera.main.fieldOfView -=2; }
if (Camera.main.orthographicSize>=1) {
Camera.main.orthographicSize -=0.5; }
}
}