using UnityEngine;
using System.Collections;

public class CameraScript : MonoBehaviour {

	public float target;
	public int goal = 0;
	public float speed = 15.2f;
	
	// Update is called once per frame
	void Start()
	{
		target = transform.position.x;
	}

	void Update () 
	{
		//if (transform.position.x < target) {
			//transform.position = new Vector3(transform.position.x + 1.5f, transform.position.y, -10);
		//}

		GameObject theplayer = GameObject.Find("Player");

		if (goal == 0) {
			if (transform.position.x < theplayer.transform.position.x + 5.2f)
			{
				transform.position = new Vector3 (transform.position.x + speed * Time.deltaTime, transform.position.y, -50);
			}
		} else {
			if (transform.position.x > theplayer.transform.position.x - 5.2f)
			{
				transform.position = new Vector3 (transform.position.x - speed * Time.deltaTime, transform.position.y, -50);
			}
		}
	}
}
