feat: Add HurtBoxOwnerGuard to prevent multiple damage registrations from the same HitBox activation
- Implemented HurtBoxOwnerGuard to ensure that multiple HurtBoxes on the same character do not register damage multiple times during a single HitBox activation. - Added custom editor for HitBox to facilitate the creation of shape colliders with HitBoxColliderProxy. - Introduced PhysicsPerceptionSystem for enemy perception, supporting multiple detection modes including RangeCircle, BatchLOS, FanCast, and BoxCast. - Created EnemyPatrolZone to define patrol and chase areas for enemies, allowing for shared zones among multiple enemies. - Added BD_IsOutsideZone conditional task for Behavior Designer to check if an enemy or player is outside a defined patrol zone.
This commit is contained in:
@@ -16,6 +16,11 @@ namespace BaseGames.Player.States
|
||||
{
|
||||
private bool _isDoubleJump;
|
||||
|
||||
// 最小跳跃窗口:窗口内松键记录 _cutPending,窗口结束时统一执行 CutJump,
|
||||
// 保证短按始终在相同 vy 时截断 → 最小跳跃高度完全一致,消除帧级手感抖动。
|
||||
private float _minJumpTimer;
|
||||
private bool _cutPending;
|
||||
|
||||
public JumpState(PlayerController owner) : base(owner) { }
|
||||
|
||||
/// <summary>
|
||||
@@ -40,6 +45,7 @@ namespace BaseGames.Player.States
|
||||
Move.Jump();
|
||||
|
||||
_isDoubleJump = false; // 消耗标记
|
||||
ResetMinJumpWindow();
|
||||
Input.JumpCancelledEvent += OnJumpCancelled;
|
||||
// 开启上升阶段贴墙 vy 保护:防止物理摩擦降低跳跃最高点
|
||||
Move.SetPreserveVyOnWallContact(true);
|
||||
@@ -96,6 +102,7 @@ namespace BaseGames.Player.States
|
||||
{
|
||||
Owner.UseAirJump();
|
||||
Move.DoubleJump();
|
||||
ResetMinJumpWindow(); // 二段跳重置最小跳跃窗口
|
||||
// 播放空中跳跃动画,未配置时回退到 Jump
|
||||
var airJumpClip = AnimCfg?.AirJump ?? AnimCfg?.Jump;
|
||||
if (airJumpClip != null) Anim?.Play(airJumpClip);
|
||||
@@ -134,6 +141,20 @@ namespace BaseGames.Player.States
|
||||
|
||||
public override void OnStateFixedUpdate()
|
||||
{
|
||||
// ── 最小跳跃窗口:窗口内松键不立即截断,窗口结束时统一处理 ─────────────
|
||||
// 保证短按(无论在窗口内哪帧松键)都在相同 vy 时执行 CutJump → 一致的最小跳跃高度。
|
||||
if (_minJumpTimer > 0f)
|
||||
{
|
||||
_minJumpTimer -= Time.fixedDeltaTime;
|
||||
if (_minJumpTimer <= 0f)
|
||||
{
|
||||
// 窗口到期:已收到松键事件,或当前键未按住(InputBuffer 延迟导致进入时键已释放)
|
||||
if (_cutPending || !Input.IsJumpHeld)
|
||||
Move.CutJump();
|
||||
_cutPending = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ── 顶点悬停:第一判断 |vy|,动态切换重力缩放系数 ────────────────
|
||||
// |垂直速度| 低于顶点阈值时,重力缩减至 ApexGravityMultiplier 倍,
|
||||
// 产生角色在跳跃顶点起起“滒空”的手感,属于高重力平台游戏的标志性特征。
|
||||
@@ -191,6 +212,18 @@ namespace BaseGames.Player.States
|
||||
Input.JumpCancelledEvent -= OnJumpCancelled;
|
||||
}
|
||||
|
||||
private void OnJumpCancelled() => Move.CutJump();
|
||||
private void OnJumpCancelled()
|
||||
{
|
||||
if (_minJumpTimer > 0f)
|
||||
_cutPending = true; // 窗口内:推迟到窗口结束时执行,保证一致的截断时机
|
||||
else
|
||||
Move.CutJump(); // 窗口已过(长按):立即截断 → 变高跳
|
||||
}
|
||||
|
||||
private void ResetMinJumpWindow()
|
||||
{
|
||||
_minJumpTimer = Cfg.MinJumpTime;
|
||||
_cutPending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user