Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Zoom : MonoBehaviour {
- public GameObject camera;
- public float speed;
- public float flOV;
- public float flOV1;
- public float deltaZoom;
- public bool upZoom;
- public bool downZoom;
- public float tmp;
- public bool a;
- void Start()
- {
- flOV = 30.0f;
- upZoom = false;
- downZoom = false;
- a = false;
- }
- void Update()
- {
- camera.GetComponent<Camera>().fieldOfView = flOV;
- if (a == true && upZoom == false && downZoom == false)
- {
- flOV = 99.99f;
- }
- if (a == false && upZoom == false && downZoom == false)
- {
- flOV = 30.0f;
- }
- if (upZoom == true)
- {
- flOV -= deltaZoom * speed * Time.deltaTime;
- if (flOV <= 15.0f)
- {
- flOV = 15.01f;
- }
- }
- if (downZoom == true)
- {
- flOV += deltaZoom * speed * Time.deltaTime;
- if (flOV >= 100.0f)
- {
- flOV = 99.99f;
- }
- }
- if (Input.GetMouseButtonDown(1))
- {
- if (a == true)
- {
- a = false;
- }
- else if (a == false)
- {
- a = true;
- }
- }
- tmp = Input.GetAxis("Mouse ScrollWheel");
- if (tmp > 0.0f)
- {
- upZoom = true;
- }
- if (tmp < 0.0f)
- {
- downZoom = true;
- }
- else if (tmp == 0.0f)
- {
- upZoom = false;
- downZoom = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement