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

public class CamerCT : MonoBehaviour
{
public Transform target;
public Vector3 offset;

//视角范围,缩放速度
public float zoomSpeed = 4f;
public float minZoom = 5f;
public float maxZoom = 10f;

public float pitch=2f;//视角高度值

private float currentZoom = 10f;//焦距

public float YawSpeed = 100f;//旋转速度
private float currentYaw = 0f;//旋转角度

// Update is called once per frame
void Update()
{
    currentZoom -= Input.GetAxis("Mouse ScrollWheel")*zoomSpeed *Time .deltaTime;
    currentZoom = Mathf.Clamp(currentZoom, minZoom, maxZoom);//限定缩放范围

    currentYaw += Input.GetAxis("Horizontal") * YawSpeed * Time.deltaTime;

}

private void LateUpdate()
{
    transform.position = target.position - offset * currentZoom;
    transform.LookAt(target.position + Vector3.up*pitch);

    transform.RotateAround(target.position, Vector3.up, currentYaw);
}

}