using UnityEngine;
using System.Collections;

public class CamFollow : MonoBehaviour
{
	public Transform player;
	public float follow;
	public float horz = 5.3f;
	public float vert = 3f;
	public float maxHor;
	public float maxVer;
	// Use this for initialization
	void Start ()
	{
		maxVer = vert - Camera.main.orthographicSize;
		maxHor = horz - 1.5f * Camera.main.aspect;
	}
	
	// Update is called once per frame
	void Update ()
	{

		Vector3 newpos = Vector3.Lerp (transform.position, new Vector3 (player.position.x, player.position.y, transform.position.z), follow);

		float x = Mathf.Clamp (newpos.x, -maxHor, maxHor);
		float y = Mathf.Clamp (newpos.y, -maxVer, maxVer);
		transform.position = new Vector3 (x, y, transform.position.z);
	
	}
}
