Merge branch 'agents/wall-jump-logic-optimization'
# Conflicts: # Assets/_Game/Scripts/Player/PlayerMovement.cs # Assets/_Game/Scripts/Player/States/IdleState.cs # Assets/_Game/Scripts/Player/States/RunState.cs # Assets/_Game/Scripts/Player/States/WallJumpState.cs # Assets/_Game/Scripts/Player/States/WallSlideState.cs
This commit is contained in:
@@ -12,6 +12,7 @@ namespace BaseGames.Player.States
|
||||
///
|
||||
/// 公共规则:
|
||||
/// 视为第一段跳(不消耗空中跳跃次数);支持可变高度(提前松键截断);
|
||||
/// 蹬墙后标记 PostWallJump,允许空中靠近墙壁时自动抓墙;
|
||||
/// 上升结束后转 FallState。
|
||||
/// </summary>
|
||||
public class WallJumpState : PlayerStateBase
|
||||
@@ -48,12 +49,17 @@ namespace BaseGames.Player.States
|
||||
|
||||
_inputLockTimer = Cfg.WallJumpInputLockDuration;
|
||||
|
||||
// 标记蹬墙跳后自动抓墙(在 FallState/JumpState 中消耗)
|
||||
Owner.SetPostWallJump(true);
|
||||
|
||||
// 蹬墙成功后立即恢复空中冲刺次数
|
||||
Owner.GetState<AerialDashState>()?.ResetAerialDashes();
|
||||
|
||||
// 播放蹬墙跳动画:背墙跳/对墙跳使用各自专属 Clip,留空时回退到 Jump 动画
|
||||
var wallJumpClip = _isAwayJump
|
||||
? (AnimCfg?.WallJumpAway ?? AnimCfg?.Jump)
|
||||
: (AnimCfg?.WallJumpToward ?? AnimCfg?.Jump);
|
||||
if (wallJumpClip != null) Anim?.Play(wallJumpClip);
|
||||
|
||||
Input.JumpCancelledEvent += OnJumpCancelled;
|
||||
}
|
||||
|
||||
@@ -64,7 +70,18 @@ namespace BaseGames.Player.States
|
||||
|
||||
public override void OnStateUpdate()
|
||||
{
|
||||
// 上升结束 → 下落
|
||||
// 输入锁结束后检查是否贴墙:自动抓墙(优先于下落判断)
|
||||
if (_inputLockTimer <= 0f)
|
||||
{
|
||||
var wd = Owner.WallDetector;
|
||||
if (wd != null && wd.IsTouchingWall && !Move.IsGrounded)
|
||||
{
|
||||
Owner.TransitionTo(Owner.GetState<WallSlideState>());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 上升结束 → 下落(isPostWallJump 标记保留,FallState 中继续支持自动抓墙)
|
||||
if (!Move.IsRising)
|
||||
{
|
||||
Owner.TransitionTo(Owner.GetState<FallState>());
|
||||
|
||||
Reference in New Issue
Block a user