Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
3,543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Tracker : MonoBehaviour {
  6.  
  7.     public GameObject target;
  8.     public GameObject cam;
  9.  
  10.     public Vector2 camRange;
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.        
  15.     }
  16.    
  17.     // Update is called once per frame
  18.     void Update () {
  19.         this.transform.position = Vector3.Lerp (this.transform.position, target.transform.position, 0.05f);
  20.         float d = Input.GetAxis ("Mouse ScrollWheel");
  21.         if (d > 0f) {
  22.             if(cam.GetComponent<Camera>().fieldOfView > camRange.x){
  23.                 cam.GetComponent<Camera> ().fieldOfView -= 2;
  24.             }
  25.         } else if(d < 0f) {
  26.             if(cam.GetComponent<Camera>().fieldOfView < camRange.y){
  27.                 cam.GetComponent<Camera> ().fieldOfView += 2;
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement