From d38505fd31783278e39764ab57b9b45cf3820e48 Mon Sep 17 00:00:00 2001 From: Joywayer Date: Thu, 21 May 2026 20:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BF=BB=E8=BD=AC=E8=A7=86?= =?UTF-8?q?=E8=A7=89=E6=9C=9D=E5=90=91=E7=9A=84=E6=96=B9=E6=B3=95=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B9=AC=E5=A2=99=E8=B7=B3=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=8D=B3=E6=97=B6=E8=BD=AC=E5=90=91=EF=BC=8C=E5=B9=B6=E5=9C=A8?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=B0=20WallSlideState=20=E6=97=B6?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E6=AD=A3=E7=A1=AE=E5=88=B7=E6=96=B0=E6=8A=93?= =?UTF-8?q?=E5=A2=99=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/_Game/Scripts/Player/PlayerMovement.cs | 11 +++++++++++ Assets/_Game/Scripts/Player/States/WallJumpState.cs | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Assets/_Game/Scripts/Player/PlayerMovement.cs b/Assets/_Game/Scripts/Player/PlayerMovement.cs index 839f95e..9cca125 100644 --- a/Assets/_Game/Scripts/Player/PlayerMovement.cs +++ b/Assets/_Game/Scripts/Player/PlayerMovement.cs @@ -236,6 +236,17 @@ namespace BaseGames.Player _rb.velocity = Vector2.zero; } + /// + /// 仅翻转视觉朝向,不修改速度。用于蹬墙跳瞬间需要立即转向而不中断跳跃速度的场景。 + /// dir:+1 = 朝右,-1 = 朝左。 + /// + public void FlipFacing(int dir) + { + if (dir == 0 || dir == _facingDirection) return; + _facingDirection = dir; + transform.localScale = new Vector3(dir, 1f, 1f); + } + // ── 取消窗口 ────────────────────────────────────────────────────────── public void SetCancelWindowOpen(bool open) => _cancelWindowOpen = open; diff --git a/Assets/_Game/Scripts/Player/States/WallJumpState.cs b/Assets/_Game/Scripts/Player/States/WallJumpState.cs index 67011c0..f9eac87 100644 --- a/Assets/_Game/Scripts/Player/States/WallJumpState.cs +++ b/Assets/_Game/Scripts/Player/States/WallJumpState.cs @@ -40,7 +40,11 @@ namespace BaseGames.Player.States { // 施加对应类型的速度 if (_isAwayJump) + { Move?.WallJumpAway(_wallDir); + // 背墙跳:立即转向远离墙壁的方向(不清零速度) + Move?.FlipFacing(-_wallDir); + } else Move?.WallJumpToward(_wallDir); @@ -76,7 +80,13 @@ namespace BaseGames.Player.States var wd = Owner.WallDetector; if (wd != null && wd.IsTouchingWall && !Move.IsGrounded) { - Owner.TransitionTo(Owner.GetState()); + // 传入真实墙壁方向,确保切换到对面墙时 WallSlideState 能正确刷新抓墙高度 + var wss = Owner.GetState(); + if (wss != null) + { + wss.PrepareEnter(wd.WallDirection); + Owner.TransitionTo(wss); + } return; } }