From 20a981535997a7342d845a18beb26a4332fce978 Mon Sep 17 00:00:00 2001 From: BobSong <605277374@qq.com> Date: Wed, 10 Sep 2025 23:52:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=90=8C=E6=AD=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ .../Unit/Unity/CharacterControllerComponent.cs | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 05130c8ff..6d310a719 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ /Assets/ResRaw/Effect/Z_Test /Assets/ResRaw/Effect/Z_Test.meta /Bundles/ +Assets/Scripts/sync.ffs_db +Assets/Scripts/sync.ffs_db.meta diff --git a/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs index acf5050e0..662122624 100644 --- a/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs +++ b/Assets/Scripts/Fishing2/Unit/Unity/CharacterControllerComponent.cs @@ -146,8 +146,16 @@ namespace NBF.Fishing2 Vector3 movementDirection = Vector3.zero; - movementDirection += Vector3.forward * movementInput.y; - movementDirection += Vector3.right * movementInput.x; + // 修改:根据角色当前朝向计算移动方向 + if (!isStop) + { + // 获取角色当前的右向和前向(在水平面上) + Vector3 characterRight = Vector3.ProjectOnPlane(characterController.transform.right, Vector3.up).normalized; + Vector3 characterForward = Vector3.ProjectOnPlane(characterController.transform.forward, Vector3.up).normalized; + + // 根据角色朝向计算实际移动方向 + movementDirection = characterForward * movementInput.y + characterRight * movementInput.x; + } Net.Send(new C2Map_Move() { @@ -293,7 +301,7 @@ namespace NBF.Fishing2 targetPosition, positionLerpSpeed * Time.deltaTime); - // 插值旋转 + // 插值旋转 - 使用更平滑的插值方法 characterController.transform.rotation = Quaternion.Slerp( characterController.transform.rotation, targetRotation, @@ -356,4 +364,4 @@ namespace NBF.Fishing2 #endregion } -} +} \ No newline at end of file