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; } }