Advertisement
jretchy

Untitled

Mar 18th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1.  
  2.     public float camSize;
  3.     public float camSizeLimit;
  4.     public float increment;
  5.     public float timeLerp;
  6.     public float timeLerpValue;
  7.  
  8.     public bool shouldZoomIn = false;
  9.     public bool shouldZoomOut = false;
  10.  
  11.     public GameObject background;
  12.     FollowUV UV;
  13.  
  14.     private void Start()
  15.     {
  16.         UV = GetComponent<FollowUV>();
  17.     }
  18.  
  19.     private void Update()
  20.     {
  21.         if (shouldZoomIn)
  22.         {
  23.             ZoomIn();
  24.         }
  25.         else if (shouldZoomOut)
  26.         {
  27.             ZoomOut();
  28.         }
  29.  
  30.         camSize = Camera.main.orthographicSize;
  31.         timeLerpValue = timeLerp * Time.deltaTime;
  32.  
  33.  
  34.  
  35.     }
  36.  
  37.     void ZoomOut()
  38.     {
  39.         if (Camera.main.orthographicSize < camSizeLimit)
  40.         {
  41.             Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, Camera.main.orthographicSize + increment, timeLerp * Time.deltaTime);
  42.         }
  43.         else if (Camera.main.orthographicSize > camSizeLimit)
  44.         {
  45.             shouldZoomOut = false;
  46.         }
  47.     }
  48.  
  49.     void ZoomIn()
  50.     {
  51.         if (Camera.main.orthographicSize > 9.665403f)
  52.         {
  53.             Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, Camera.main.orthographicSize + -increment, timeLerp * Time.deltaTime);
  54.         }
  55.         else if (Camera.main.orthographicSize < 9.665403f)
  56.         {
  57.             shouldZoomIn = false;
  58.         }
  59.  
  60.     }
  61.  
  62.     private void OnTriggerEnter2D(Collider2D col)
  63.     {
  64.         if (col.gameObject.tag == "ZoomInTrigger")
  65.         {
  66.             shouldZoomIn = true;
  67.         }
  68.         else if (col.gameObject.tag == "ZoomOutTrigger")
  69.         {
  70.             shouldZoomOut = true;
  71.         }
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement