Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class main_camera : MonoBehaviour {
  5.  
  6. private Vector2 velocity;
  7.  
  8. public float smoothTimeX;
  9. public float smoothTimeY;
  10.  
  11. public float cameraSize;
  12. public float newCameraSize;
  13.  
  14. public GameObject focusOn;
  15.  
  16. public float vel;
  17. public float sT = 0.1f;
  18.  
  19. // Use this for initialization
  20. void Start () {
  21. cameraSize = Camera.main.orthographicSize;
  22. newCameraSize = cameraSize;
  23. }
  24.  
  25. public void Info(GameObject fO, float sTX, float sTY, float nCS){
  26. focusOn = fO;
  27. smoothTimeX = sTX;
  28. smoothTimeY = sTY;
  29. if (nCS != 0) {
  30. newCameraSize = nCS;
  31. }
  32. }
  33.  
  34. void FixedUpdate(){
  35. float posX = Mathf.SmoothDamp (transform.position.x, focusOn.transform.position.x, ref velocity.x, smoothTimeX);
  36. float posY = Mathf.SmoothDamp (transform.position.y, focusOn.transform.position.y, ref velocity.y, smoothTimeY);
  37.  
  38. float cSize = Mathf.SmoothDamp (cameraSize, newCameraSize, ref vel, sT);
  39. cameraSize = cSize;
  40.  
  41. transform.position = new Vector3 (posX, posY, transform.position.z);
  42.  
  43. Camera.main.orthographicSize = cSize;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement