diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index 2abbb06..56fe9b1 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -320,23 +320,19 @@ namespace Platformer.Mechanics // BT90 — 수평 Raycast 영역 폐기 (BT89 거짓 양성 — 같은 Tile cell 영역 검출) // 벽 영역 = stuckTimer 영역 (50ms 정지 시 즉시 phase+2)으로 처리 - // BT12-Dev 2026-05-12 — cliffCheck 매 frame + 양측 검사 (PD: 발판 폭 좁을 시 제자리 대기) + // BT12-Dev 2026-05-12 — cliffCheck Enemy 영역 가장자리 상대 (PD: 발판 가장자리 걸쳐 대기 정정) + // 절대 cliffCheckDistance 폐기·bounds.extents.x + edgeMargin 사용 → Enemy 영역 바로 앞 검사 if (_collider != null) { - Vector2 footAheadFwd = new Vector2( - _collider.bounds.center.x + moveDir * cliffCheckDistance, - _collider.bounds.min.y + 0.05f - ); - RaycastHit2D groundHitFwd = Physics2D.Raycast(footAheadFwd, Vector2.down, cliffCheckDepth, groundLayerMask); + const float EDGE_MARGIN = 0.15f; + float fwdX = _collider.bounds.center.x + moveDir * (_collider.bounds.extents.x + EDGE_MARGIN); + float backX = _collider.bounds.center.x - moveDir * (_collider.bounds.extents.x + EDGE_MARGIN); + float footY = _collider.bounds.min.y + 0.05f; + RaycastHit2D groundHitFwd = Physics2D.Raycast(new Vector2(fwdX, footY), Vector2.down, cliffCheckDepth, groundLayerMask); if (groundHitFwd.collider == null) { - // 전방 cliff — 반대편도 검사. 반대편도 cliff면 발판 폭 좁음 → 제자리 대기. - Vector2 footAheadBack = new Vector2( - _collider.bounds.center.x - moveDir * cliffCheckDistance, - _collider.bounds.min.y + 0.05f - ); - RaycastHit2D groundHitBack = Physics2D.Raycast(footAheadBack, Vector2.down, cliffCheckDepth, groundLayerMask); + RaycastHit2D groundHitBack = Physics2D.Raycast(new Vector2(backX, footY), Vector2.down, cliffCheckDepth, groundLayerMask); if (groundHitBack.collider == null) { // 양측 cliff — 제자리 대기 @@ -345,7 +341,6 @@ namespace Platformer.Mechanics _stuckTimer = 0f; return; } - // 전방만 cliff — 방향 전환 TriggerReverse(moveDir, 0.3f); return; }