using System; using System.Collections; using System.Collections.Generic; using DS; using UnityEngine; public class PlayerManager : MonoBehaviour { private InputHandler _inputHandler; private Animator _animator; public bool isInteracting; private CameraHandler _cameraHandler; // 相机处理器单例引用 private PlayerLocomotion _playerLocomotion; private void Start() { // 获取相机处理器的单例引用,用于在 FixedUpdate 中驱动相机跟随与旋转 _cameraHandler = CameraHandler.singleton; _inputHandler = GetComponent(); _animator = GetComponentInChildren(); _playerLocomotion = GetComponent(); } private void Update() { 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); } } }