修复内容:

PlayerMovement:新增 _facingLocked 字段 + LockFacing(bool) 方法;UpdateFacing() 锁定时直接返回
WallSlideState:OnStateEnter 调用 LockFacing(true) + FlipFacing(_wallDir);OnStateExit 调用 LockFacing(false) 解锁
WallJumpState:OnStateEnter 保险性再调一次 LockFacing(false);WallJumpAway/Toward 同步写入 _inputVelocityX,确保解锁后 UpdateFacing 朝向正确(背墙跳 = 离墙方向,对墙跳 = 朝墙方向)
This commit is contained in:
2026-05-22 10:48:52 +08:00
parent 285ac46e31
commit 68d4c699ae
15 changed files with 235 additions and 418 deletions

View File

@@ -38,6 +38,9 @@ namespace BaseGames.Player.States
public override void OnStateEnter()
{
// 蹬墙时解锁自动朝向(由 WallSlideState.OnStateExit 已解锁,这里保险再做一次)
Move?.LockFacing(false);
// 施加对应类型的速度
if (_isAwayJump)
{

View File

@@ -62,6 +62,11 @@ namespace BaseGames.Player.States
_lastGrabDir = _wallDir;
}
// 锁定自动朝向,防止 LateUpdate 的 UpdateFacing 覆盖手动设置的朝向
Move?.LockFacing(true);
// 抓墙时始终面朝墙壁,确保背墙跳的 FlipFacing(-_wallDir) 能正确翻转朝向
Move?.FlipFacing(_wallDir);
// 计算当前是否处于正常模式
UpdateCanJump();
@@ -76,6 +81,7 @@ namespace BaseGames.Player.States
public override void OnStateExit()
{
Move?.LockFacing(false);
Input.JumpStartedEvent -= OnJumpPressed;
}
@@ -98,6 +104,25 @@ namespace BaseGames.Player.States
return;
}
// ── 抓墙攻击:优先于方向键脱离检测,朝离墙方向翻转后进入空中攻击(无土狼时间)──
if (Buffer.ConsumeAttack())
{
Move.FlipFacing(-_wallDir);
Owner.TransitionTo(Owner.GetState<AirAttackState>());
return;
}
// ── 抓墙冲刺:优先于方向键脱离检测,朝离墙方向翻转后冲出(无土狼时间)──────────
var ds = Owner.GetState<DashState>();
if (ds != null && ds.CanDashMidAir
&& Stats != null && Stats.HasAbility(AbilityType.Dash)
&& Buffer.ConsumeDash())
{
Move.FlipFacing(-_wallDir);
Owner.TransitionTo(ds);
return;
}
// 按下方向键 → 启动墙壁土狼时间后主动脱离,自然下落
if (Input.MoveInput.y < -0.5f)
{
@@ -107,7 +132,6 @@ namespace BaseGames.Player.States
}
// 按反方向键 → 启动墙壁土狼时间后脱离
// wall coyote 存在时,离墙后短窗口内仍可触发蹬墙跳,不会误双跳
float mx = Input.MoveInput.x;
if (Mathf.Abs(mx) > 0.1f && (mx > 0f ? 1 : -1) != _wallDir)
{