diff --git a/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs b/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs index b262e6f..1983881 100644 --- a/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs +++ b/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs @@ -25,10 +25,10 @@ namespace Platformer.Gameplay // 0 = 닿음 / 양수 = Player 발이 Enemy 머리 위 / 음수 = Player 발이 Enemy 머리 영역 안 영역 // 측면 충돌 시 footHeadDelta 음수 (Player 발 영역 < Enemy 머리 영역) // 점프 밟기 시 footHeadDelta -0.2 ~ +0.3 영역 (착지 직전·직후) - // BT5-Dev #28 — 시각 정합: Player Collider Offset y +0.10 + Enemy sprite 위 여백 ≈ 0.1 - // 시각 발이 Enemy 시각 머리 영역 안 0.05~0.4 침투 시점 = PD "발 닿는 느낌" 정합 - const float STOMP_DELTA_MIN = -0.4f; - const float STOMP_DELTA_MAX = -0.05f; + // BT5-Dev #30 — dyAtCollision 영역 시각 영역 정합 (Player·Enemy 시각 영역 보정 적용) + // 0 = Player 시각 발이 Enemy 시각 머리 정확히 닿음. 음수 = Player 발이 Enemy 영역 안 침투. + const float STOMP_DELTA_MIN = -0.3f; // Enemy 영역 안 0.3 단위 침투까지 허용 + const float STOMP_DELTA_MAX = 0.05f; // Enemy 머리 영역 약간 위(0.05)까지 허용 PlatformerModel model = Simulation.GetModel(); diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index 00e151b..01a4d8a 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -108,13 +108,14 @@ namespace Platformer.Mechanics } if (_cachedPlayer != null && _cachedPlayer.health != null && _cachedPlayer.health.IsAlive) { - // BT5-Dev #25 — Bounds 기반 dy: Player 발 vs Enemy 머리 영역 (PD 의도 정합) + // BT5-Dev #30 — 시각 영역 정합 보정: Player Collider 발(Bounds.min.y)이 시각 발보다 ~0.17 단위 위 (Offset y +0.10) Vector3 ePos = transform.position; Vector3 pPos = _cachedPlayer.transform.position; float dx = Mathf.Abs(pPos.x - ePos.x); - float footY = _cachedPlayer.Bounds.min.y; // Player 발 world y - float headY = VisualBounds.max.y; // Enemy 머리 world y - float footHeadDelta = footY - headY; // 0 = 닿음 / 양수 = Player 발 위 / 음수 = Player 발 아래 + const float PLAYER_COLLIDER_TO_VISUAL_FOOT = -0.17f; // Hero1 sprite 발 위치 보정 + float footY = _cachedPlayer.Bounds.min.y + PLAYER_COLLIDER_TO_VISUAL_FOOT; // Player 시각 발 + float headY = VisualBounds.max.y; // Enemy 시각 머리 (sprite 위 여백 ≈ 0) + float footHeadDelta = footY - headY; // 0 = 시각 발이 시각 머리 닿음 bool inRange = dx < hitRangeX && Mathf.Abs(pPos.y - ePos.y) < hitRangeY; diff --git a/Assets/Scripts/Mechanics/PlayerController.cs b/Assets/Scripts/Mechanics/PlayerController.cs index 73b1591..c0e7dba 100644 --- a/Assets/Scripts/Mechanics/PlayerController.cs +++ b/Assets/Scripts/Mechanics/PlayerController.cs @@ -111,6 +111,15 @@ namespace Platformer.Mechanics } } + // BT5-Dev #30 — 발판 GameObject 영역 식별 진단 (PD 영역 영역 영역 부딪힘 시 Console 출력) + void OnCollisionEnter2D(Collision2D col) + { + if (col.gameObject == null) return; + int layer = col.gameObject.layer; + string name = col.gameObject.name; + Debug.Log($"[BT30-Collide] name='{name}' layer={layer} (8=JumpThrough, 0=Default)"); + } + void OnHealthDeath() { controlEnabled = false;