diff options
| author | SmallFox <2806143047@qq.com> | 2026-06-02 20:02:14 +0800 |
|---|---|---|
| committer | SmallFox <2806143047@qq.com> | 2026-06-03 21:12:19 +0800 |
| commit | 364bd0db3dba9a0cc80f76cb465d80209922557f (patch) | |
| tree | 138e414a8f1426307288af61d63c13a81f9b3033 /Assets/Scripts/PlayerManager.cs | |
| parent | 5b955377fd4aae7cb24c2b16c15fe3ba20ceae8a (diff) | |
小写一点
Diffstat (limited to 'Assets/Scripts/PlayerManager.cs')
| -rw-r--r-- | Assets/Scripts/PlayerManager.cs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index e80c0a2..25b16f0 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -8,17 +8,51 @@ public class PlayerManager : MonoBehaviour { private InputHandler _inputHandler; private Animator _animator; + + public bool isInteracting; + private CameraHandler _cameraHandler; // 相机处理器单例引用 + private PlayerLocomotion _playerLocomotion; + + + private void Awake() + { + // 获取相机处理器的单例引用,用于在 FixedUpdate 中驱动相机跟随与旋转 + _cameraHandler = CameraHandler.singleton; + } private void Start() { _inputHandler = GetComponent<InputHandler>(); _animator = GetComponentInChildren<Animator>(); + _playerLocomotion = GetComponent<PlayerLocomotion>(); } private void Update() { - _inputHandler.isInteracting = _animator.GetBool("isInteracting"); + float delta = Time.deltaTime; + + isInteracting = _animator.GetBool("isInteracting"); _inputHandler.rollFlag = false; _inputHandler.sprintFlag = false; + + _playerLocomotion.isSprinting = _inputHandler.b_Input; + // 处理输入(读取水平/垂直输入值) + _inputHandler.TickInput(delta); + _playerLocomotion.UpdateCharacterMovement(delta); + _playerLocomotion.HandleRollingAndSpringting(delta); + + } + + private void FixedUpdate() + { + float delta = Time.fixedDeltaTime; // 固定时间步长,确保物理一致性 + + if (_cameraHandler != null) + { + // 让相机跟随目标(通常是玩家角色) + _cameraHandler.FollowTarget(delta); + // 根据鼠标/摇杆输入旋转相机 + _cameraHandler.HandleCameraRotation(delta, _inputHandler.mouseX,_inputHandler.mouseY); + } } } |
