BT5-Dev #44: 일반 지면(Level Tilemap) Layer 0 + 공중 발판(Foreground·Alien) Layer 16 분리

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) 영역 = 걸어가면 통과·점프해도 통과·위에서 떨어지면 착지
This commit is contained in:
깃 관리자 2026-05-07 18:29:59 +09:00
parent 41c4b9e506
commit 2294da9264
1 changed files with 23 additions and 8 deletions

View File

@ -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<Collider2D>(FindObjectsSortMode.None);
var appliedNames = new System.Collections.Generic.List<string>();
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<UnityEngine.Tilemaps.TilemapCollider2D>() != null && c.gameObject.name == "Level")
{
if (c.gameObject.layer == 16) c.gameObject.layer = 0; // BT38·BT40·BT43 잔존 복원
levelKept++;
continue;
}
var effector = c.GetComponent<PlatformEffector2D>();
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<UnityEngine.Tilemaps.TilemapCollider2D>();
if (fgTc == null) fgTc = foreground.AddComponent<UnityEngine.Tilemaps.TilemapCollider2D>();
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)}]");
}
}
}