using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {
    public GameObject player;
    public float yMax;
    public float yMin;
	// Use this for initialization
	void Start () {
        transform.position = new Vector3(player.transform.position.x, player.transform.position.y, transform.position.z);
    }
	
	// Update is called once per frame
	void LateUpdate () {
        var playerPosition = player.transform.position;
        float ypos = playerPosition.y;
        if (playerPosition.y > yMax)
            ypos = yMax;

        if (ypos < yMin)
            ypos = yMin;

        transform.position = new Vector3(transform.position.x, ypos, transform.position.z);
        //Debug.Log("My position: " + transform.position);
        //Debug.Log("Player position: " + player.transform.position);
    }
}
