From f86c25987c023fcc80c21c6f40da1e79af96ab45 Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Wed, 3 Jun 2026 07:37:22 +0800 Subject: 增加冲刺时的相机视角变化 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/CameraFOVBinding.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Assets/Scripts/CameraFOVBinding.cs (limited to 'Assets/Scripts/CameraFOVBinding.cs') diff --git a/Assets/Scripts/CameraFOVBinding.cs b/Assets/Scripts/CameraFOVBinding.cs new file mode 100644 index 0000000..1275fe8 --- /dev/null +++ b/Assets/Scripts/CameraFOVBinding.cs @@ -0,0 +1,25 @@ +using System; +using DS; +using UnityEngine; + +[RequireComponent(typeof(CameraHandler))] +public class CameraFOVBinding : MonoBehaviour +{ + public Camera camera; + public float normalFOV; + public float runningFOV; + private CameraHandler _cameraHandler; + private PlayerLocomotion _playerLocomotion; + + private void Start() + { + _cameraHandler = GetComponent(); + _playerLocomotion = _cameraHandler.player.gameObject.GetComponent(); + } + + private void FixedUpdate() + { + var targetFOV = _playerLocomotion.isSprinting ? runningFOV : normalFOV; + camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, targetFOV, 0.12f); + } +} -- cgit