49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 上梯子后才能使用鼠标滑轮控制视角
|
|
/// </summary>
|
|
public class RoleMove : MonoBehaviour
|
|
{
|
|
public static RoleMove instance;
|
|
public bool isup;
|
|
|
|
public void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
void Update()
|
|
{
|
|
MouseScrollWheel();
|
|
}
|
|
|
|
public void MouseScrollWheel()
|
|
{
|
|
if (isup)
|
|
{
|
|
FirstPersonController.instance.playerCanMove = false;
|
|
|
|
//通过鼠标滚轮放大和缩放视角
|
|
//放大视角 往前滑
|
|
if (Input.GetAxis("Mouse ScrollWheel") < 0)
|
|
{
|
|
if (Camera.main.fieldOfView <= 55) //小于一个放大范围后就不继续放大了
|
|
{
|
|
Camera.main.fieldOfView += 5;
|
|
}
|
|
}
|
|
//减小视角 往后滑
|
|
if (Input.GetAxis("Mouse ScrollWheel") > 0)
|
|
{
|
|
if (Camera.main.fieldOfView >= 30)
|
|
{
|
|
Camera.main.fieldOfView -= 5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|