diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index 2758419..2778352 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -68,17 +68,40 @@ namespace Platformer.Mechanics if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})"); } - // BT47 — Foreground TilemapCollider2D + Layer 16 (ColliderType Sprite 강제는 Tile 이동 후 한 번에 처리) - // BT65 — PD 명시 (2026-05-08): "직전 상태로 되돌려" = BT64 폐기 → BT63 회귀. - var foreground = GameObject.Find("Foreground"); + // BT66 — PD 결정 R2 (2026-05-08): 자동 분류 결과 = 별도 GameObject (AutoForeground). + // PD Foreground GameObject = PD 직접 그린 가림막 시각만 (TilemapCollider 제거). + // AutoForeground GameObject (신규·Grid 자식) = 본 PM 자동 분류 발판 + TilemapCollider + Layer 16 + Drop-Through. + // 결과: PD 시각 의도 (가림막 영역) 분리 + 자동 분류 발판 영역 별도 + Drop-Through 패턴 작동. + + // 1. PD Foreground = 가림막 시각만. 기존 TilemapCollider2D 제거 (충돌 X). + var pdForeground = GameObject.Find("Foreground"); + if (pdForeground != null) + { + var pdFgTc = pdForeground.GetComponent(); + if (pdFgTc != null) Object.Destroy(pdFgTc); + } + + // 2. AutoForeground GameObject 신규 생성 (Grid 자식) — 자동 분류 발판 전용. + GameObject gridGo = (pdForeground != null && pdForeground.transform.parent != null) + ? pdForeground.transform.parent.gameObject + : GameObject.Find("Grid"); + GameObject autoFg = GameObject.Find("AutoForeground"); UnityEngine.Tilemaps.Tilemap fgTilemap = null; UnityEngine.Tilemaps.TilemapCollider2D fgTc = null; - if (foreground != null) + if (autoFg == null && gridGo != null) { - fgTc = foreground.GetComponent(); - if (fgTc == null) fgTc = foreground.AddComponent(); - foreground.layer = 16; - fgTilemap = foreground.GetComponent(); + autoFg = new GameObject("AutoForeground"); + autoFg.transform.SetParent(gridGo.transform, false); + } + if (autoFg != null) + { + autoFg.layer = 16; + fgTilemap = autoFg.GetComponent(); + if (fgTilemap == null) fgTilemap = autoFg.AddComponent(); + if (autoFg.GetComponent() == null) + autoFg.AddComponent(); + fgTc = autoFg.GetComponent(); + if (fgTc == null) fgTc = autoFg.AddComponent(); } // BT48 — Level → Foreground 자동 분류 강화. 분류 조건 2종 결합: