diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index 8083730..9c8b8c3 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -29,10 +29,9 @@ namespace Platformer.Mechanics public float cliffCheckDistance = 0.3f; // 발 앞 절벽 검출 거리 (BT86: 0.6→0.3 — 더 빠른 검출·낭떠러지 근처 Enemy 보호) public float cliffCheckDepth = 1.5f; // 발 아래 Raycast 거리 public LayerMask groundLayerMask = (1 << 0) | (1 << 16); // Layer 0 (지면) + Layer 16 (발판) - public float stuckThresholdTime = 0.1f; // 벽 정지 검출 시간 (보조·수평 Raycast 미감지 시 fallback) - public float stuckMoveThreshold = 0.02f; // 정지 판정 거리 임계값 (미세 밀림 검출) - public float wallCheckDistance = 0.1f; // BT89: 수평 벽 Raycast distance (bounds 외부 0.05+0.1=0.15m·인접 Tile 검출 X) - public float waitMinTime = 1f; // BT89: patrol arrive 후 대기 random 영역 + public float stuckThresholdTime = 0.05f; // BT90: 0.1→0.05 (50ms·거의 즉시) + public float stuckMoveThreshold = 0.02f; // 정지 판정 거리 임계값 (미세 밀림 검출) + public float waitMinTime = 1f; // patrol arrive·벽·절벽 후 대기 random 영역 public float waitMaxTime = 3f; private float _startX; @@ -132,26 +131,8 @@ namespace Platformer.Mechanics float moveDir = Mathf.Sign(dx); - // 즉시 벽 검출 — 수평 Raycast (bounds 외부 + 0.1m·인접 Tile X) → phase+2 즉시 전환 - if (_collider != null) - { - float halfWidth = _collider.bounds.extents.x; - Vector2 wallOrigin = new Vector2( - _collider.bounds.center.x + moveDir * (halfWidth + 0.05f), - _collider.bounds.center.y - ); - RaycastHit2D wallHit = Physics2D.Raycast(wallOrigin, new Vector2(moveDir, 0), wallCheckDistance, groundLayerMask); - if (wallHit.collider != null) - { - _patrolPhase = (_patrolPhase + 2) % 4; - SetNextPatrolTarget(); - _waitTimer = Random.Range(waitMinTime, waitMaxTime); - if (control != null) control.move.x = 0f; - _stuckTimer = 0f; - _lastX = transform.position.x; - return; - } - } + // BT90 — 수평 Raycast 영역 폐기 (BT89 거짓 양성 — 같은 Tile cell 영역 검출) + // 벽 영역 = stuckTimer 영역 (50ms 정지 시 즉시 phase+2)으로 처리 // 절벽 검출 — 발 앞 Raycast 지면 X 시 phase+2 즉시 전환 (대기) if (_collider != null)