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

public class RotateCamera : MonoBehaviour
{
    public float horizontalRotSpeed = 15;
    public float verticalRotSpeed = 15;
    public float minVert = 0;
    public float maxVert = 80;

    void Update ()
    {
        if (Input.GetMouseButton(2))
        {
            var parenteuler = transform.parent.localRotation.eulerAngles;
            parenteuler.y += Input.GetAxis("Mouse X") * horizontalRotSpeed * Time.deltaTime;
            transform.parent.localRotation = Quaternion.Euler(parenteuler);
            var euler = transform.localRotation.eulerAngles;
            euler.x -= Input.GetAxis("Mouse Y") * verticalRotSpeed * Time.deltaTime;
            euler.x = Mathf.Clamp(euler.x, minVert, maxVert);
            transform.localRotation = Quaternion.Euler(euler);
        }
    }
}
