using UnityEngine;
using System.Collections;

public class CameraManager : MonoBehaviour {

    float fixedYValue;
    public Transform target;            
    public float smoothing = 5f;      

    Vector3 offset;


    void Start()
    {
        
        offset = transform.position - target.position;
        fixedYValue = Camera.main.transform.position.y;
    }
	void LateUpdate () {
        Camera.main.transform.position = target.position + offset;
        transform.position = Vector3.Lerp(transform.position, Camera.main.transform.position, smoothing * Time.deltaTime);
        Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, fixedYValue,Camera.main.transform.transform.position.z);
	}
}
