diff --git a/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs index 1e97215df..976e92933 100644 --- a/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs +++ b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs @@ -268,8 +268,8 @@ namespace NBF.Fishing2 private void UpdateMovement() { - var movementDirection = - currentMoveState.moveDirection.relativeTo(BaseCamera.Main.transform, characterController.transform.up); + // 修改:使用世界坐标方向而不是相对坐标方向 + Vector3 movementDirection = currentMoveState.moveDirection; Vector3 movement = movementDirection * currentMoveState.moveSpeed * Time.deltaTime; networkPosition += movement; @@ -315,6 +315,7 @@ namespace NBF.Fishing2 private Vector3 _rotationInput = Vector3.zero; private float rotationSyncTimer; private Vector3 lastSyncedFacing; + private bool isRotating = false; [Tooltip("视角旋转敏感度")] public Vector2 sensitivity = new Vector2(0.015f, 0.015f); @@ -327,17 +328,15 @@ namespace NBF.Fishing2 if (lookInput.x != 0.0f) { _rotationInput.y += lookInput.x; + isRotating = true; } - - // 应用旋转到角色和相机 if (_rotationInput != Vector3.zero) { characterController.transform.rotation *= Quaternion.Euler(0, _rotationInput.y, 0); _rotationInput = Vector3.zero; } - } // 检查朝向同步 @@ -348,15 +347,17 @@ namespace NBF.Fishing2 { float angleChange = Vector3.Angle(transform.forward, lastSyncedFacing); - if (angleChange >= minRotationChange) + // 修改:即使在旋转中也定期同步朝向,避免累积误差 + if (angleChange >= minRotationChange || isRotating) { SendLookMessage(); lastSyncedFacing = transform.forward; rotationSyncTimer = 0f; + isRotating = false; } } } #endregion } -} +} \ No newline at end of file