Skip to content
Snippets Groups Projects
CameraMovement.cs 638 B
using UnityEngine;
using System.Collections;

public class CameraMovement : MonoBehaviour {

    public Transform follow;
    Camera cam;

	// Use this for initialization
	void Start () {
        cam = GetComponent<Camera>();
	}
	
	// Update is called once per frame
	void Update () {
        //changing screen height won't screw the sprites. (mobile capatability, etc.)
        cam.orthographicSize = (Screen.height / 100f) / 2f;

        //Lerp parameters (from, to, how fast)
        if (follow) {
            transform.position = Vector3.Lerp(transform.position, follow.position, 0.1f) + new Vector3(0, 0.08f, -10);
        }
	}
}