BT5-Dev #39: 점프 시작 시 Coroutine 0.3초 IgnoreLayerCollision (Physics step 지연 차단)

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 → 발판 위 착지
This commit is contained in:
깃 관리자 2026-05-07 18:11:09 +09:00
parent e5c5898f79
commit 48f1084504
1 changed files with 15 additions and 5 deletions

View File

@ -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)