diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-03 07:37:22 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-03 07:37:22 +0800 |
| commit | f86c25987c023fcc80c21c6f40da1e79af96ab45 (patch) | |
| tree | 3f29f99638c7531b12b7b0c4411331f6bf92e2b7 /Assets/Scripts/CameraFOVBinding.cs | |
| parent | 65c80579d0791026ae1a2fd5327f3e520973c09b (diff) | |
增加冲刺时的相机视角变化
Diffstat (limited to 'Assets/Scripts/CameraFOVBinding.cs')
| -rw-r--r-- | Assets/Scripts/CameraFOVBinding.cs | 25 |
1 files changed, 25 insertions, 0 deletions
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<CameraHandler>(); + _playerLocomotion = _cameraHandler.player.gameObject.GetComponent<PlayerLocomotion>(); + } + + private void FixedUpdate() + { + var targetFOV = _playerLocomotion.isSprinting ? runningFOV : normalFOV; + camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, targetFOV, 0.12f); + } +} |
