diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index 965ea9d..1b43337 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -60,10 +60,9 @@ namespace Platformer.Mechanics applied++; if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})"); } - 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); + 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 동적 갱신 } } } diff --git a/Assets/Scripts/Mechanics/PlayerController.cs b/Assets/Scripts/Mechanics/PlayerController.cs index f513c92..f7485e5 100644 --- a/Assets/Scripts/Mechanics/PlayerController.cs +++ b/Assets/Scripts/Mechanics/PlayerController.cs @@ -157,9 +157,9 @@ namespace Platformer.Mechanics if (IsGrounded) LastGroundedPosition = transform.position; } - // BT5-Dev #39 — 점프 시작 시 Coroutine으로 0.3초 동안 Layer 16 통과 유지 (Physics step 지연 차단) + // BT5-Dev #40 — 개발팀장 진단: KinematicObject.Start() contactFilter 캐싱 우회 + // Physics2D.IgnoreLayerCollision은 raycast contactFilter 영역 무관. SetLayerMask 직접 갱신 의무. const int JUMP_THROUGH_LAYER = 16; - bool _jumpThroughActive; void UpdateJumpState() { @@ -170,8 +170,6 @@ namespace Platformer.Mechanics jumpState = JumpState.Jumping; jump = true; stopJump = false; - // BT39 — 점프 시작 시 즉시 IgnoreLayerCollision 활성 + Coroutine으로 0.3초 유지 - if (!_jumpThroughActive) StartCoroutine(JumpThroughRoutine()); break; case JumpState.Jumping: if (!IsGrounded) @@ -191,15 +189,18 @@ namespace Platformer.Mechanics jumpState = JumpState.Grounded; break; } + + // BT40 — Drop-Through: velocity.y > 0(상승) 영역 Layer 16 mask 비활성, 그 외 활성 + UpdateContactFilterForDropThrough(); } - System.Collections.IEnumerator JumpThroughRoutine() + void UpdateContactFilterForDropThrough() { - _jumpThroughActive = true; - Physics2D.IgnoreLayerCollision(13, JUMP_THROUGH_LAYER, true); - yield return new WaitForSeconds(0.3f); - Physics2D.IgnoreLayerCollision(13, JUMP_THROUGH_LAYER, false); - _jumpThroughActive = false; + int baseMask = Physics2D.GetLayerCollisionMask(gameObject.layer); + bool ascending = velocity.y > 0.01f; + int mask = ascending ? (baseMask & ~(1 << JUMP_THROUGH_LAYER)) : baseMask; + contactFilter.SetLayerMask(mask); + contactFilter.useLayerMask = true; } protected override void ComputeVelocity()