From e5c5898f797ac757d23ea09766b57cd6c9a6facf Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 18:07:54 +0900 Subject: [PATCH] =?UTF-8?q?BT5-Dev=20#38:=20Layer=2016(JumpThrough)=20+=20?= =?UTF-8?q?=EB=8F=99=EC=A0=81=20IgnoreLayerCollision=20=ED=86=A0=EA=B8=80?= =?UTF-8?q?=20(PD=20=EC=A0=9C=EC=95=88=20=EC=B1=84=ED=83=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PD 보고: 발판 통과 X 여전 (BT35 PlatformEffector2D+Composite 영역 동작 X) PD 제안: 충돌 로직 바꿔서 해결 표준 Drop-Through 패턴: - Tilemap·Alien Layer 16 변환 (BT38) - 기본: Player(13) ↔ JumpThrough(16) 충돌 ON = 정상 착지 - PlayerController.Update: velocity.y > 0.05 (상승) → IgnoreLayerCollision(13, 16, true) = 모든 발판 통과 - velocity.y <= 0.05 (하강·정지) → IgnoreLayerCollision(13, 16, false) = 충돌 ON = 착지 폐기: - PlatformEffector2D·CompositeCollider2D·Rigidbody2D Static (BT35 영역) - Layer 8·PlatformDropThrough Raycast (BT27·BT31 영역) 동작 (PD 의도 정합): - Player 점프 상승 → 발판 모두 통과 - Player 하강 → 발판 위 착지 - 옆·아래에서 점프 → 통과 (상승 영역 모든 Layer 16 OFF) --- Assets/Scripts/Mechanics/GameOptimizer.cs | 50 +++++--------------- Assets/Scripts/Mechanics/PlayerController.cs | 5 ++ 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index 3d50858..965ea9d 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 #34 — Unity 표준 OneWay Platform = PlatformEffector2D + useOneWay + surfaceArc 180. - // 모든 일반 Collider(Tilemap 포함) PlatformEffector2D 적용. Layer 영역 무관 (기본 Layer 0 유지). - // 동작: 위에서 떨어지면 충돌(착지) / 옆·아래·점프 상승 시 통과 + // BT5-Dev #38 — 표준 Drop-Through 패턴: Layer 16(JumpThrough) + 동적 IgnoreLayerCollision 토글 + // 점프 상승 = IgnoreLayerCollision(13, 16, true) 통과 / 하강 = false 충돌 ON int applied = 0, excluded = 0; var allColliders = Object.FindObjectsByType(FindObjectsSortMode.None); var appliedNames = new System.Collections.Generic.List(); @@ -51,45 +50,20 @@ namespace Platformer.Mechanics continue; } - if (c.gameObject.layer == 8) c.gameObject.layer = 0; - - // BT5-Dev #35 — TilemapCollider2D 영역 표준 패턴 (CompositeCollider2D + Rigidbody2D Static + PlatformEffector2D) - var tilemapCollider = c.GetComponent(); - if (tilemapCollider != null) - { - tilemapCollider.compositeOperation = Collider2D.CompositeOperation.Merge; - var composite = c.GetComponent(); - if (composite == null) composite = c.gameObject.AddComponent(); - var rb = c.GetComponent(); - if (rb == null) rb = c.gameObject.AddComponent(); - rb.bodyType = RigidbodyType2D.Static; - composite.usedByEffector = true; - var compositeEffector = c.GetComponent(); - if (compositeEffector == null) compositeEffector = c.gameObject.AddComponent(); - compositeEffector.useOneWay = true; - compositeEffector.surfaceArc = 180f; - compositeEffector.rotationalOffset = 0f; - compositeEffector.useSideFriction = false; - compositeEffector.useSideBounce = false; - applied++; - if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}(Tilemap+Composite)"); - continue; - } - - // 일반 Collider — PlatformEffector2D 직접 적용 - c.usedByEffector = true; + // BT38 — PlatformEffector2D·CompositeCollider2D·Rigidbody2D 영역 영역 영역 폐기 var effector = c.GetComponent(); - if (effector == null) effector = c.gameObject.AddComponent(); - effector.useOneWay = true; - effector.surfaceArc = 180f; - effector.rotationalOffset = 0f; - effector.useSideFriction = false; - effector.useSideBounce = false; + 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($"[BT35-OneWay] applied={applied} excluded={excluded} total={allColliders.Length}"); - Debug.Log($"[BT35-OneWay] appliedSamples=[{string.Join(", ", appliedNames)}]"); + Debug.Log($"[BT38-DropThrough] applied={applied} excluded={excluded} total={allColliders.Length}"); + Debug.Log($"[BT38-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); + // 기본 = Player(13) ↔ JumpThrough(16) 충돌 ON. PlayerController.Update에서 점프 시 동적 토글 + Physics2D.IgnoreLayerCollision(13, 16, false); } } } diff --git a/Assets/Scripts/Mechanics/PlayerController.cs b/Assets/Scripts/Mechanics/PlayerController.cs index cae4ade..5f03c31 100644 --- a/Assets/Scripts/Mechanics/PlayerController.cs +++ b/Assets/Scripts/Mechanics/PlayerController.cs @@ -155,6 +155,11 @@ namespace Platformer.Mechanics // PD 지시 2026-05-07 — 낙사 시 복귀할 안전 위치 추적 if (IsGrounded) LastGroundedPosition = transform.position; + + // BT5-Dev #38 — 표준 Drop-Through: 점프 상승(velocity.y > 0) Layer 16 통과·하강(≤0) 충돌 ON + const int JUMP_THROUGH_LAYER = 16; + bool rising = velocity.y > 0.05f; + Physics2D.IgnoreLayerCollision(13, JUMP_THROUGH_LAYER, rising); } void UpdateJumpState()