From 2294da9264350b52a1b01f879a5f71c1ac495361 Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 18:29:59 +0900 Subject: [PATCH] =?UTF-8?q?BT5-Dev=20#44:=20=EC=9D=BC=EB=B0=98=20=EC=A7=80?= =?UTF-8?q?=EB=A9=B4(Level=20Tilemap)=20Layer=200=20+=20=EA=B3=B5=EC=A4=91?= =?UTF-8?q?=20=EB=B0=9C=ED=8C=90(Foreground=C2=B7Alien)=20Layer=2016=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PD 의도 정확 파악: - 이동할 때 통과 = '공중에 떠있지만 이동 경로에 걸리는 발판' - 바닥(Level Tilemap) = 일반 충돌 (서 있어야 함) - 공중 발판 = Drop-Through (걷기·점프 모두 통과) 본 PM 자인: - BT38부터 모든 Collider Layer 16 변환 = Level Tilemap도 Drop-Through - PD 의도(일반 지면 영역 영역 X) 정합 X 정정: - Level Tilemap (TilemapCollider2D + name='Level') = Layer 0 그대로 (BT38·BT40·BT43 잔존 복원) - Foreground GameObject = TilemapCollider2D 동적 추가 + Layer 16 (공중 발판) - 별개 BoxCollider2D (Alien 등) = Layer 16 동작: - Level Tilemap 위 = Player 일반 충돌 = 안 떨어짐 - 공중 발판(Foreground·Alien) 영역 = 걸어가면 통과·점프해도 통과·위에서 떨어지면 착지 --- Assets/Scripts/Mechanics/GameOptimizer.cs | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index 1b43337..91a4cd7 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -30,9 +30,8 @@ namespace Platformer.Mechanics [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] static void SetupJumpThroughPlatforms() { - // BT5-Dev #38 — 표준 Drop-Through 패턴: Layer 16(JumpThrough) + 동적 IgnoreLayerCollision 토글 - // 점프 상승 = IgnoreLayerCollision(13, 16, true) 통과 / 하강 = false 충돌 ON - int applied = 0, excluded = 0; + // BT5-Dev #44 — 일반 지면(Level Tilemap) Layer 0 일반 충돌 + 공중 발판(Foreground·별개 BoxCollider2D)만 Layer 16 + int applied = 0, excluded = 0, levelKept = 0; var allColliders = Object.FindObjectsByType(FindObjectsSortMode.None); var appliedNames = new System.Collections.Generic.List(); foreach (var c in allColliders) @@ -50,19 +49,35 @@ namespace Platformer.Mechanics continue; } - // BT38 — PlatformEffector2D·CompositeCollider2D·Rigidbody2D 영역 영역 영역 폐기 + // BT44 — Level Tilemap (TilemapCollider2D) = 일반 지면 Layer 0 그대로 (Drop-Through 영역 외) + if (c.GetComponent() != null && c.gameObject.name == "Level") + { + if (c.gameObject.layer == 16) c.gameObject.layer = 0; // BT38·BT40·BT43 잔존 복원 + levelKept++; + continue; + } + var effector = c.GetComponent(); if (effector != null) Object.Destroy(effector); c.usedByEffector = false; - // Layer 16(JumpThrough) 변환 c.gameObject.layer = 16; applied++; if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})"); } - Debug.Log($"[BT40-DropThrough] applied={applied} excluded={excluded} total={allColliders.Length}"); - Debug.Log($"[BT40-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); - // BT40 — Layer Matrix는 항시 ON. PlayerController.UpdateContactFilterForDropThrough에서 raycast contactFilter mask 동적 갱신 + + // BT44 — Foreground GameObject(시각만·Collider 미부착) → TilemapCollider2D 동적 추가 + Layer 16 (공중 발판) + var foreground = GameObject.Find("Foreground"); + if (foreground != null) + { + var fgTc = foreground.GetComponent(); + if (fgTc == null) fgTc = foreground.AddComponent(); + foreground.layer = 16; + Debug.Log($"[BT44-Foreground] TilemapCollider2D + Layer 16 applied to 'Foreground'"); + } + + Debug.Log($"[BT44-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); + Debug.Log($"[BT44-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); } } }