BT5-Dev #20: IgnoreCollision Update fallback + const STOMP_MIN_DY 0.8 + velocity.y<0

This commit is contained in:
깃 관리자 2026-05-07 15:55:18 +09:00
parent db6bb2051d
commit e5eb9ecafb
2 changed files with 20 additions and 3 deletions

View File

@ -21,16 +21,20 @@ namespace Platformer.Gameplay
/// <summary>BT5-Dev #16 — EnemyController.Update에서 측정한 Player·Enemy y 차 (밟기 판정 영역).</summary>
public float dyAtCollision;
// BT5-Dev #20 — Enemy.prefab 직렬화 영역 우회 영역 const 영역
// Player.height 1.15 + Enemy.height 1.26 → 발 닿는 영역 dy ≈ 1.0
const float STOMP_MIN_DY = 0.8f;
PlatformerModel model = Simulation.GetModel<PlatformerModel>();
public override void Execute()
{
if (player == null || player.health == null || enemy == null) return;
// BT5-Dev #16 — Distance 기반 밟기 판정. dyAtCollision > stompMinDy = Player가 Enemy 위에서 밟음.
bool stomped = dyAtCollision > enemy.stompMinDy;
// BT5-Dev #20 — 밟기 영역: Player 발이 Enemy 영역 위 + 하강 중 (점프 후 영역 보장)
bool stomped = dyAtCollision > STOMP_MIN_DY && player.velocity.y < 0f;
Debug.Log($"[PEC] stomped={stomped} dy={dyAtCollision:F2} (threshold>{enemy.stompMinDy}) pInvuln={player.health.IsInvulnerable}");
Debug.Log($"[PEC] stomped={stomped} dy={dyAtCollision:F2} vy={player.velocity.y:F2} (thr>{STOMP_MIN_DY}, vy<0) pInvuln={player.health.IsInvulnerable}");
if (stomped)
{

View File

@ -37,6 +37,7 @@ namespace Platformer.Mechanics
public Bounds VisualBounds => spriteRenderer != null ? spriteRenderer.bounds : _collider.bounds;
PlayerController _cachedPlayer;
bool _ignoreCollisionApplied;
void Awake()
{
@ -85,6 +86,18 @@ namespace Platformer.Mechanics
Debug.Log($"[BT17-Update@{name}] f={Time.frameCount} cached={(_cachedPlayer != null ? _cachedPlayer.name : "NULL")} pgoTag={(pgo != null ? pgo.name : "NULL")} allPCcount={allCount}");
}
}
// BT20 — IgnoreCollision 영역 Awake 시점 Player 발견 X 영역 fallback. Update 영역에서 발견 직후 1회 영역 호출.
if (_cachedPlayer != null && !_ignoreCollisionApplied && _collider != null)
{
var pc = _cachedPlayer.GetComponent<Collider2D>();
if (pc != null)
{
Physics2D.IgnoreCollision(_collider, pc, true);
_ignoreCollisionApplied = true;
Debug.Log($"[BT20-Ignore@{name}] Player↔Enemy IgnoreCollision applied");
}
}
if (_cachedPlayer != null && _cachedPlayer.health != null && _cachedPlayer.health.IsAlive)
{
// BT5-Dev #16 — Distance 기반 단순 감지 (Bounds 영역 산수 영역 의존 X·항상 작동)