using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameraControl : MonoBehaviour
{
//鼠标右键按下后移动鼠标控制视角围绕小球旋转,同时视角一直跟随小球。
public Transform target; // 要围绕的目标物体,要在unity中把物体拖进来
public float distance = 5.0f; // 距离
public float xSpeed = 120.0f; // 水平旋转速度
public float ySpeed = 120.0f; // 垂直旋转速度
private float x = 0.0f;
private float y = 0.0f;
//滚轮控制视角缩放
private Camera cam;
public float zoomSpeed = 10f; // 缩放速度
public float minFOV = 5f; // 最小视野角度
public float maxFOV = 150f; // 最大视野角度
// Start is called before the first frame update
void Start()
{
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
// 使摄像机始终面向目标
transform.LookAt(target);
transform.RotateAround(target.position, Vector3.up, -