From b84c236761acaf44325acd6e5f992db9aaacaaef Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 21:27:11 +0900 Subject: [PATCH] =?UTF-8?q?BT5-Dev=20#48:=20=EC=9E=91=EC=9D=80=20=EA=B3=B5?= =?UTF-8?q?=EC=A4=91=20=EB=B0=9C=ED=8C=90=20=EC=9E=90=EB=8F=99=20=EB=B6=84?= =?UTF-8?q?=EB=A5=98=20=EA=B0=95=ED=99=94=20(=EC=9C=84=C2=B7=EC=95=84?= =?UTF-8?q?=EB=9E=98=20=EB=B9=88=20=EA=B3=B5=EA=B0=84=20+=20=EA=B0=80?= =?UTF-8?q?=EB=A1=9C=20=E2=89=A48=20tile)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BT47 단일 임계값(playerY+1.5) 의존 한계: 첨부 이미지 같은 낮은 위치 발판 누락. BT48 분류 조건 2종 결합: - (a) 임계값 위 = 무조건 공중 (BT47 호환) - (b) 임계값 아래여도 위·아래 인접 Tile 모두 빈 공간 + 가로 연속 길이 ≤8 tile = 작은 공중 발판 → 일반 지면(통상 10+ tile) 잘못 분류 방지 + PD 의도 발판 자동 포함 표준 One-Way Platform / Drop-Through 패턴 정합 (Layer 16 + ContactFilter2D 동적 mask). 8 tile 임계값 = 추정 proxy (일반 platformer 지면 10+ tile 가정·실측 미확증). PD 시각 검증 후 의도와 다른 발판 분류 시 임계값 조정 또는 알고리즘 재설계 후속. PD Editor Refresh+Play 시 Console [BT48-MoveTiles] high=N smallAir=M 출력으로 분류 결과 검증 가능. 본 PM 직접 Editor.log read 의무 (PD 시각 검증 결과 보고 직후). --- Assets/Scripts/Mechanics/GameOptimizer.cs | 48 ++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index b5a8c02..32bbd28 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -80,7 +80,10 @@ namespace Platformer.Mechanics fgTilemap = foreground.GetComponent(); } - // BT47 — Level Tilemap의 공중 Tile (Player 시작 Y + 1.5 이상 영역) 영역 → Foreground 영역 자동 이동 + // BT48 — Level → Foreground 자동 분류 강화. 분류 조건 2종 결합: + // (a) 임계값 위 (worldY >= playerY + 1.5) = 공중 = 무조건 Foreground (BT47 호환) + // (b) 임계값 아래여도 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 8 tile 이하 = 작은 공중 발판 + // → 일반 지면(통상 10+ tile 가로) 잘못 분류 방지 + 첨부 이미지 같은 작은 발판 자동 분류 var levelGo = GameObject.Find("Level"); if (levelGo != null && fgTilemap != null) { @@ -89,9 +92,10 @@ namespace Platformer.Mechanics if (levelTilemap != null && player != null) { float playerY = player.transform.position.y; - float airThresholdY = playerY + 1.5f; // Player 시작 Y + 1.5 위 = 공중 발판 영역 + float airThresholdY = playerY + 1.5f; // Player 시작 Y + 1.5 위 = 공중 (BT47 호환) + const int MAX_PLATFORM_WIDTH = 8; var bounds = levelTilemap.cellBounds; - int moved = 0; + int movedHigh = 0, movedSmall = 0; for (int x = bounds.xMin; x <= bounds.xMax; x++) { for (int y = bounds.yMin; y <= bounds.yMax; y++) @@ -99,24 +103,50 @@ namespace Platformer.Mechanics var pos = new Vector3Int(x, y, 0); if (!levelTilemap.HasTile(pos)) continue; Vector3 worldPos = levelTilemap.CellToWorld(pos); - if (worldPos.y < airThresholdY) continue; // 지면·벽 영역 그대로 - // 공중 영역 Tile → Foreground 영역 영역 이동 + bool aboveThreshold = worldPos.y >= airThresholdY; + bool isSmallAir = !aboveThreshold && IsSmallAirPlatform(levelTilemap, pos, MAX_PLATFORM_WIDTH); + if (!aboveThreshold && !isSmallAir) continue; var tile = levelTilemap.GetTile(pos); fgTilemap.SetTile(pos, tile); fgTilemap.SetColliderType(pos, UnityEngine.Tilemaps.Tile.ColliderType.Sprite); levelTilemap.SetTile(pos, null); - moved++; + if (aboveThreshold) movedHigh++; + else movedSmall++; } } if (fgTc != null) fgTc.ProcessTilemapChanges(); var lvlTc = levelGo.GetComponent(); if (lvlTc != null) lvlTc.ProcessTilemapChanges(); - Debug.Log($"[BT47-MoveTiles] moved={moved} air tiles from Level (worldY>={airThresholdY:F2}) to Foreground"); + Debug.Log($"[BT48-MoveTiles] moved={movedHigh + movedSmall} (high={movedHigh} thresholdY={airThresholdY:F2} / smallAir={movedSmall} maxWidth={MAX_PLATFORM_WIDTH})"); } } - Debug.Log($"[BT47-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); - Debug.Log($"[BT47-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); + Debug.Log($"[BT48-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); + Debug.Log($"[BT48-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); + } + + /// + /// BT48 — 작은 공중 발판 판별. 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 maxWidth 이하. + /// 일반 지면(통상 10+ tile 가로) 잘못 분류 방지. + /// + static bool IsSmallAirPlatform(UnityEngine.Tilemaps.Tilemap tm, Vector3Int pos, int maxWidth) + { + if (tm.HasTile(pos + Vector3Int.up)) return false; + if (tm.HasTile(pos + Vector3Int.down)) return false; + int width = 1; + for (int dx = 1; dx <= maxWidth; dx++) + { + if (!tm.HasTile(pos + new Vector3Int(dx, 0, 0))) break; + width++; + if (width > maxWidth) return false; + } + for (int dx = 1; dx <= maxWidth; dx++) + { + if (!tm.HasTile(pos + new Vector3Int(-dx, 0, 0))) break; + width++; + if (width > maxWidth) return false; + } + return width <= maxWidth; } } }