From e5eb9ecafbfd6baffc5e2b9ae3f512b91f007257 Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 15:55:18 +0900 Subject: [PATCH] BT5-Dev #20: IgnoreCollision Update fallback + const STOMP_MIN_DY 0.8 + velocity.y<0 --- Assets/Scripts/Gameplay/PlayerEnemyCollision.cs | 10 +++++++--- Assets/Scripts/Mechanics/EnemyController.cs | 13 +++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs b/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs index 89b192e..7f200e5 100644 --- a/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs +++ b/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs @@ -21,16 +21,20 @@ namespace Platformer.Gameplay /// BT5-Dev #16 — EnemyController.Update에서 측정한 Player·Enemy y 차 (밟기 판정 영역). 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(); 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) { diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index eadbf4a..b67e8bb 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -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(); + 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·항상 작동)