Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class main_camera : MonoBehaviour {
- private Vector2 velocity;
- public float smoothTimeX;
- public float smoothTimeY;
- public float cameraSize;
- public float newCameraSize;
- public GameObject focusOn;
- public float vel;
- public float sT = 0.1f;
- // Use this for initialization
- void Start () {
- cameraSize = Camera.main.orthographicSize;
- newCameraSize = cameraSize;
- }
- public void Info(GameObject fO, float sTX, float sTY, float nCS){
- focusOn = fO;
- smoothTimeX = sTX;
- smoothTimeY = sTY;
- if (nCS != 0) {
- newCameraSize = nCS;
- }
- }
- void FixedUpdate(){
- float posX = Mathf.SmoothDamp (transform.position.x, focusOn.transform.position.x, ref velocity.x, smoothTimeX);
- float posY = Mathf.SmoothDamp (transform.position.y, focusOn.transform.position.y, ref velocity.y, smoothTimeY);
- float cSize = Mathf.SmoothDamp (cameraSize, newCameraSize, ref vel, sT);
- cameraSize = cSize;
- transform.position = new Vector3 (posX, posY, transform.position.z);
- Camera.main.orthographicSize = cSize;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement