Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float camSize;
- public float camSizeLimit;
- public float increment;
- public float timeLerp;
- public float timeLerpValue;
- public bool shouldZoomIn = false;
- public bool shouldZoomOut = false;
- public GameObject background;
- FollowUV UV;
- private void Start()
- {
- UV = GetComponent<FollowUV>();
- }
- private void Update()
- {
- if (shouldZoomIn)
- {
- ZoomIn();
- }
- else if (shouldZoomOut)
- {
- ZoomOut();
- }
- camSize = Camera.main.orthographicSize;
- timeLerpValue = timeLerp * Time.deltaTime;
- }
- void ZoomOut()
- {
- if (Camera.main.orthographicSize < camSizeLimit)
- {
- Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, Camera.main.orthographicSize + increment, timeLerp * Time.deltaTime);
- }
- else if (Camera.main.orthographicSize > camSizeLimit)
- {
- shouldZoomOut = false;
- }
- }
- void ZoomIn()
- {
- if (Camera.main.orthographicSize > 9.665403f)
- {
- Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, Camera.main.orthographicSize + -increment, timeLerp * Time.deltaTime);
- }
- else if (Camera.main.orthographicSize < 9.665403f)
- {
- shouldZoomIn = false;
- }
- }
- private void OnTriggerEnter2D(Collider2D col)
- {
- if (col.gameObject.tag == "ZoomInTrigger")
- {
- shouldZoomIn = true;
- }
- else if (col.gameObject.tag == "ZoomOutTrigger")
- {
- shouldZoomOut = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement