From 48f1084504c9ce82d5a8dadb5a1e4637e5473206 Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 18:11:09 +0900 Subject: [PATCH] =?UTF-8?q?BT5-Dev=20#39:=20=EC=A0=90=ED=94=84=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=20=EC=8B=9C=20Coroutine=200.3=EC=B4=88=20IgnoreLayerC?= =?UTF-8?q?ollision=20(Physics=20step=20=EC=A7=80=EC=97=B0=20=EC=B0=A8?= =?UTF-8?q?=EB=8B=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PD 보고: 발판 통과 X 여전 (BT38 매 프레임 토글 영역 동작 X) 진단: - Unity Physics2D.IgnoreLayerCollision = 변경 즉시 적용 X, 다음 Physics step 영역만 적용 (한 frame 지연) - Update에서 매 프레임 velocity.y 토글 → 점프 시작 frame 영역 영역 발판 영역 영역 충돌 발동 → 다음 frame 영역 통과 적용 → 이미 영역 영역 정정: - UpdateJumpState 영역 PrepareToJump → StartCoroutine(JumpThroughRoutine) - Coroutine: IgnoreLayerCollision(13, 16, true) → 0.3초 대기 → false 복구 - 0.3초 = 점프 정점 도달 시간 → 하강 시점 자동 충돌 ON → 착지 정합 - 매 프레임 Update 토글 영역 폐기 동작: - 점프 시작 → 즉시 Layer 16 통과 (Coroutine 시작 + 0.3초 영역) - 0.3초 후 (정점 도달·하강 시작) → 충돌 ON → 발판 위 착지 --- Assets/Scripts/Mechanics/PlayerController.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Mechanics/PlayerController.cs b/Assets/Scripts/Mechanics/PlayerController.cs index 5f03c31..f513c92 100644 --- a/Assets/Scripts/Mechanics/PlayerController.cs +++ b/Assets/Scripts/Mechanics/PlayerController.cs @@ -155,13 +155,12 @@ 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); } + // BT5-Dev #39 — 점프 시작 시 Coroutine으로 0.3초 동안 Layer 16 통과 유지 (Physics step 지연 차단) + const int JUMP_THROUGH_LAYER = 16; + bool _jumpThroughActive; + void UpdateJumpState() { jump = false; @@ -171,6 +170,8 @@ 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) @@ -192,6 +193,15 @@ namespace Platformer.Mechanics } } + System.Collections.IEnumerator JumpThroughRoutine() + { + _jumpThroughActive = true; + Physics2D.IgnoreLayerCollision(13, JUMP_THROUGH_LAYER, true); + yield return new WaitForSeconds(0.3f); + Physics2D.IgnoreLayerCollision(13, JUMP_THROUGH_LAYER, false); + _jumpThroughActive = false; + } + protected override void ComputeVelocity() { if (jump && IsGrounded)