diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index 695286d..94ee410 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -105,37 +105,8 @@ namespace Platformer.Mechanics // BT104 — 시작 위치 발판 검증·자동 재배치 (PD가 PD Foreground·빈 영역 배치 시 가까운 발판 영역으로 이동) void Start() { - if (_collider != null) - { - Vector2 footHere = new Vector2(_collider.bounds.center.x, _collider.bounds.min.y + 0.05f); - RaycastHit2D groundUnder = Physics2D.Raycast(footHere, Vector2.down, cliffCheckDepth, groundLayerMask); - if (groundUnder.collider == null) - { - // 시작 위치 발판 X — 가까운 좌·우 발판 자동 검색 - for (float d = 0.5f; d <= 50f; d += 0.5f) - { - Vector2 rightProbe = new Vector2(_startX + d, footHere.y); - if (Physics2D.Raycast(rightProbe, Vector2.down, cliffCheckDepth, groundLayerMask).collider != null) - { - _startX += d; - Vector3 newPos = new Vector3(_startX, transform.position.y, transform.position.z); - transform.position = newPos; - if (_body != null) _body.position = newPos; - break; - } - Vector2 leftProbe = new Vector2(_startX - d, footHere.y); - if (Physics2D.Raycast(leftProbe, Vector2.down, cliffCheckDepth, groundLayerMask).collider != null) - { - _startX -= d; - Vector3 newPos = new Vector3(_startX, transform.position.y, transform.position.z); - transform.position = newPos; - if (_body != null) _body.position = newPos; - break; - } - } - } - } - _startY = transform.position.y; // 재배치 후 _startY 갱신 + // BT109 — Raycast 영역 폐기 (BT104 영역 부정확). Tilemap cell 기반 시작 위치 발판 검증. + _startY = transform.position.y; _maxRightRange = MeasureSafeWalkDistance(1f); _maxLeftRange = MeasureSafeWalkDistance(-1f); @@ -188,8 +159,10 @@ namespace Platformer.Mechanics } if (groundTilemaps.Count == 0) return 0f; - // 시작 cell = Enemy 발 아래 cell - Vector3 footPos = new Vector3(_startX, _collider.bounds.min.y - 0.1f, 0f); + // BT109 — footPos 영역 정정 (PD 보고 2026-05-08: 이동 X) + // bounds.min.y - 0.1f = Enemy 발 영역 cell → 발판 cell X + // → bounds.min.y - 0.5f = 발판 cell 영역 정확 검사 + Vector3 footPos = new Vector3(_startX, _collider.bounds.min.y - 0.5f, 0f); UnityEngine.Tilemaps.Tilemap startTm = null; Vector3Int startCell = Vector3Int.zero; foreach (var tm in groundTilemaps) @@ -202,6 +175,7 @@ namespace Platformer.Mechanics break; } } + Debug.Log($"[Enemy@{name}] dir={dir} footPos.y={footPos.y:F2} startTm={(startTm!=null?startTm.name:"NULL")} startCell={startCell}"); if (startTm == null) return 0f; // 좌·우 연속 Tile 영역 끝 영역 검색