From 364bd0db3dba9a0cc80f76cb465d80209922557f Mon Sep 17 00:00:00 2001 From: SmallFox <2806143047@qq.com> Date: Tue, 2 Jun 2026 20:02:14 +0800 Subject: 小写一点 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/PlayerManager.cs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'Assets/Scripts/PlayerManager.cs') 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(); _animator = GetComponentInChildren(); + _playerLocomotion = GetComponent(); } 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); + } } } -- cgit