Advertisement
SawneyStudios

Tutorial Camera -Script

Mar 20th, 2019
3,577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TutorialCamera : MonoBehaviour
  6. {
  7.  
  8.     public GameObject target;
  9.     public float xSpeed = 3.5f;
  10.     float sensitivity = 17f;
  11.  
  12.     float minFov = 35;
  13.     float maxFov = 100;
  14.  
  15.  
  16.     // Update is called once per frame
  17.     void Update()
  18.     {
  19.  
  20.         if (Input.GetMouseButton(1)) {
  21.  
  22.             transform.RotateAround(target.transform.position, transform.up, Input.GetAxis("Mouse X") * xSpeed);
  23.             transform.RotateAround(target.transform.position, transform.right, -Input.GetAxis("Mouse Y") * xSpeed);
  24.  
  25.         }
  26.  
  27.         //ZOOM
  28.  
  29.         float fov = Camera.main.fieldOfView;
  30.         fov += Input.GetAxis("Mouse ScrollWheel") * -sensitivity;
  31.         fov = Mathf.Clamp(fov, minFov, maxFov);
  32.         Camera.main.fieldOfView = fov;
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement