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

public class CameraController : MonoBehaviour {

	public float rotateSpeed = 75;
	public float returnSpeed = 2;


	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetMouseButton (0)) {

			transform.Rotate (-Input.GetAxis ("Mouse Y") * rotateSpeed * Time.deltaTime, Input.GetAxis ("Mouse X") * rotateSpeed * Time.deltaTime, 0);
			Quaternion q = transform.rotation;
			q.eulerAngles = new Vector3 (q.eulerAngles.x, q.eulerAngles.y, 0);
			transform.rotation = q;

		} else {
			transform.localRotation = Quaternion.Lerp(transform.localRotation,Quaternion.identity,returnSpeed * Time.deltaTime);
		}
	}
}
