diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index 9c8b8c3..86fd716 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -26,8 +26,8 @@ namespace Platformer.Mechanics public float patrolMinRange = 50f; public float patrolMaxRange = 75f; public float patrolArriveThreshold = 0.5f; - public float cliffCheckDistance = 0.3f; // 발 앞 절벽 검출 거리 (BT86: 0.6→0.3 — 더 빠른 검출·낭떠러지 근처 Enemy 보호) - public float cliffCheckDepth = 1.5f; // 발 아래 Raycast 거리 + public float cliffCheckDistance = 0.8f; // BT91: 0.3→0.8 — 더 일찍 검출 (Enemy 이동 속도 대비 충분한 영역) + public float cliffCheckDepth = 2.0f; // BT91: 1.5→2.0 — 더 깊게 검출 public LayerMask groundLayerMask = (1 << 0) | (1 << 16); // Layer 0 (지면) + Layer 16 (발판) public float stuckThresholdTime = 0.05f; // BT90: 0.1→0.05 (50ms·거의 즉시) public float stuckMoveThreshold = 0.02f; // 정지 판정 거리 임계값 (미세 밀림 검출) @@ -134,7 +134,7 @@ namespace Platformer.Mechanics // BT90 — 수평 Raycast 영역 폐기 (BT89 거짓 양성 — 같은 Tile cell 영역 검출) // 벽 영역 = stuckTimer 영역 (50ms 정지 시 즉시 phase+2)으로 처리 - // 절벽 검출 — 발 앞 Raycast 지면 X 시 phase+2 즉시 전환 (대기) + // BT91 — 절벽 검출: 즉시 반대 방향 이동 (waitTimer X — 정지 시 절벽 떨어짐) if (_collider != null) { Vector2 footAhead = new Vector2( @@ -146,15 +146,15 @@ namespace Platformer.Mechanics { _patrolPhase = (_patrolPhase + 2) % 4; SetNextPatrolTarget(); - _waitTimer = Random.Range(waitMinTime, waitMaxTime); - if (control != null) control.move.x = 0f; _stuckTimer = 0f; _lastX = transform.position.x; + dx = _targetX - transform.position.x; + if (control != null) control.move.x = Mathf.Clamp(dx, -1, 1); return; } } - // stuckTimer 보조 — 수평 Raycast 미감지 fallback (벽 정지 + 미세 밀림 0.1초 후 phase+2) + // BT91 — 벽 정지 (stuckTimer): 즉시 반대 방향 이동 (waitTimer X — 부들부들 차단) if (Mathf.Abs(transform.position.x - _lastX) < stuckMoveThreshold) { _stuckTimer += Time.deltaTime; @@ -162,10 +162,10 @@ namespace Platformer.Mechanics { _patrolPhase = (_patrolPhase + 2) % 4; SetNextPatrolTarget(); - _waitTimer = Random.Range(waitMinTime, waitMaxTime); - if (control != null) control.move.x = 0f; _stuckTimer = 0f; _lastX = transform.position.x; + dx = _targetX - transform.position.x; + if (control != null) control.move.x = Mathf.Clamp(dx, -1, 1); return; } }