添加翻转视觉朝向的方法以支持蹬墙跳时的即时转向,并在切换到 WallSlideState 时确保正确刷新抓墙高度
This commit is contained in:
@@ -236,6 +236,17 @@ namespace BaseGames.Player
|
||||
_rb.velocity = Vector2.zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仅翻转视觉朝向,不修改速度。用于蹬墙跳瞬间需要立即转向而不中断跳跃速度的场景。
|
||||
/// dir:+1 = 朝右,-1 = 朝左。
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
|
||||
@@ -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>());
|
||||
// 传入真实墙壁方向,确保切换到对面墙时 WallSlideState 能正确刷新抓墙高度
|
||||
var wss = Owner.GetState<WallSlideState>();
|
||||
if (wss != null)
|
||||
{
|
||||
wss.PrepareEnter(wd.WallDirection);
|
||||
Owner.TransitionTo(wss);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user