﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour {
	public GameObject followObject;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (this.followObject != null) {
			Vector3 followPosition = this.followObject.transform.position;

			followPosition.z = this.transform.position.z;
			followPosition.x += Mathf.Clamp (0.3f * (Camera.main.ScreenToWorldPoint (Input.mousePosition).x - followPosition.x), Camera.main.rect.width * -1f, Camera.main.rect.width);
			followPosition.y += Mathf.Clamp (0.3f * (Camera.main.ScreenToWorldPoint (Input.mousePosition).y - followPosition.y), Camera.main.rect.height * -1f, Camera.main.rect.height);

			this.transform.position = followPosition;
		}
	}
}
