创建相机跟随脚本
创建相机漫游脚本
创建相机切换脚本
将漫游和跟随放到切换脚本的公开变量上
跟随脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraScroll : MonoBehaviour
{
public Camera cam; // 相机
private float camFOV; // 相机视野
public float zoomSpeed; // 缩放速度
private float mouseScrollInput; // 鼠标滚动输入
// Start is called before the first frame update
void Start()
{
camFOV = cam.fieldOfView;
// 获取到相机视野
}
// Update is called once per frame
void Update()
{
// 获取到鼠标的滚轮的状态
mouseScrollInput = Input.