From 874f58a66e26188c263d8fec9b0bd2ae99d4fcac Mon Sep 17 00:00:00 2001 From: swrring Date: Thu, 7 May 2026 16:00:40 +0900 Subject: [PATCH] =?UTF-8?q?BT5-Dev=20#21:=20vy=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=ED=8F=90=EA=B8=B0=C2=B7Awake=20fallback=20IgnoreCollision?= =?UTF-8?q?=C2=B7OneWay=20=EB=94=94=EB=B2=84=EA=B7=B8=20=EA=B0=95=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Gameplay/PlayerEnemyCollision.cs | 7 ++--- Assets/Scripts/Mechanics/EnemyController.cs | 14 +++++++--- Assets/Scripts/Mechanics/GameOptimizer.cs | 26 ++++++++++++------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs b/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs index 7f200e5..62223a8 100644 --- a/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs +++ b/Assets/Scripts/Gameplay/PlayerEnemyCollision.cs @@ -31,10 +31,11 @@ namespace Platformer.Gameplay { if (player == null || player.health == null || enemy == null) return; - // BT5-Dev #20 — 밟기 영역: Player 발이 Enemy 영역 위 + 하강 중 (점프 후 영역 보장) - bool stomped = dyAtCollision > STOMP_MIN_DY && player.velocity.y < 0f; + // BT5-Dev #21 — 밟기 영역: Player 발이 Enemy 영역 위 (체공 상승·하강 모두 영역 — vy 조건 폐기) + // dy > STOMP_MIN_DY 영역에서 점프 영역 보장됨 (측면 닿음 영역 dy ≈ 0). vy<0 조건은 상승 시점 측면 피격 오인 발동 + bool stomped = dyAtCollision > STOMP_MIN_DY; - Debug.Log($"[PEC] stomped={stomped} dy={dyAtCollision:F2} vy={player.velocity.y:F2} (thr>{STOMP_MIN_DY}, vy<0) pInvuln={player.health.IsInvulnerable}"); + Debug.Log($"[PEC] stomped={stomped} dy={dyAtCollision:F2} vy={player.velocity.y:F2} (thr>{STOMP_MIN_DY}) pInvuln={player.health.IsInvulnerable}"); if (stomped) { diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs index b67e8bb..5e580d2 100644 --- a/Assets/Scripts/Mechanics/EnemyController.cs +++ b/Assets/Scripts/Mechanics/EnemyController.cs @@ -46,13 +46,21 @@ namespace Platformer.Mechanics _audio = GetComponent(); spriteRenderer = GetComponent(); - // PD 지시 2026-05-07 — Player ↔ Enemy 물리 충돌 무시 (통과 가능). 감지는 Bounds.Intersects 별도. - // Enemy Collider 일반 유지 (지면 충돌 영역 보존) → 등장 정합. + // BT5-Dev #21 — Awake 시점 fallback 추가 (Player tag 영역 미설정 영역 대비) var playerObj = GameObject.FindGameObjectWithTag("Player"); + if (playerObj == null) + { + var pcfb = Object.FindFirstObjectByType(); + if (pcfb != null) playerObj = pcfb.gameObject; + } if (playerObj != null && _collider != null) { var pc = playerObj.GetComponent(); - if (pc != null) Physics2D.IgnoreCollision(_collider, pc, true); + if (pc != null) + { + Physics2D.IgnoreCollision(_collider, pc, true); + _ignoreCollisionApplied = true; + } } // BT5-Dev #17 marker — 본 영역 출력 시 새 코드 영역 적용 정합. 출력 X = Editor Asset Refresh 영역 미수행 diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index 5d6b2e7..47e987f 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -25,18 +25,24 @@ namespace Platformer.Mechanics static void SetupOneWayPlatforms() { int applied = 0; + int excludedTrigger = 0, excludedActor = 0; var allColliders = Object.FindObjectsByType(FindObjectsSortMode.None); + var appliedNames = new System.Collections.Generic.List(); + var excludedNames = new System.Collections.Generic.List(); foreach (var c in allColliders) { if (c == null) continue; - if (c.isTrigger) continue; - // Player·Enemy·기타 GameObject 영역 제외 - if (c.GetComponent() != null) continue; - if (c.GetComponent() != null) continue; - if (c.GetComponent() != null) continue; - if (c.GetComponent() != null) continue; - if (c.GetComponent() != null) continue; - if (c.GetComponent() != null) continue; + if (c.isTrigger) { excludedTrigger++; continue; } + if (c.GetComponent() != null + || c.GetComponent() != null + || c.GetComponent() != null + || c.GetComponent() != null + || c.GetComponent() != null + || c.GetComponent() != null) + { + excludedActor++; + continue; + } c.usedByEffector = true; var effector = c.GetComponent(); @@ -47,8 +53,10 @@ namespace Platformer.Mechanics effector.useSideFriction = false; effector.useSideBounce = false; applied++; + if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})"); } - Debug.Log($"[BT19-OneWay] applied={applied} totalColliders={allColliders.Length}"); + Debug.Log($"[BT21-OneWay] applied={applied} trigger={excludedTrigger} actor={excludedActor} total={allColliders.Length}"); + Debug.Log($"[BT21-OneWay] appliedSamples=[{string.Join(", ", appliedNames)}]"); } } }