Advertisement
Guest User

Untitled

a guest
May 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. void Update() { //paste it in your Update method
  2.  
  3.     if (Input.GetKeyCode(KeyCode.Z)) {
  4.  
  5.         StartCoroutine(WaitThenCallThisConstantly(0.0005f,0.0075f,counter,maxTimes));
  6.     }
  7. }
  8.  
  9. IEnumerator WaitThenCallThisConstantly(float time,float smoothTime,int counter,int maxTimes) {
  10.  
  11.     yield return new WaitForSeconds (time);
  12.  
  13.     float zoom = 4.25f; float smooth = 5.0f;
  14.     float normal = 4.95f; //increase this to a bigger value to zoom out even more
  15.  
  16.  
  17.     counter++;
  18.     if (counter < maxTimes) {
  19.  
  20.         mainCamera.orthographicSize = Mathf.Lerp(mainCamera.orthographicSize,normal,Time.deltaTime * (counter/2.0f) *smooth);
  21.         StartCoroutine(WaitThenCallThisConstantly(time,smoothTime,counter,maxTimes));
  22.  
  23.     }    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement