From 35923be06dc4f7ea71ca18c1c31b93f2b49e74f2 Mon Sep 17 00:00:00 2001 From: swrring Date: Tue, 12 May 2026 17:57:01 +0900 Subject: [PATCH] =?UTF-8?q?fix(BT12-Dev):=20KinematicObject=20base=20magic?= =?UTF-8?q?=20method=20override=C2=B7body=20=EC=B4=88=EA=B8=B0=ED=99=94=20?= =?UTF-8?q?(Enemy=20=EC=98=81=EA=B5=AC=20=EC=A0=95=EC=A7=80=20=EA=B7=BC?= =?UTF-8?q?=EB=B3=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PD: "여전히 움직이지 않아·실측해보고 근본 원인 체크" 근본 (MCP Play 실측·자성 #12·#13): - KinematicObject.OnEnable·Start·Update·FixedUpdate 모두 `protected virtual` - AnimationController는 KinematicObject 상속하지만 override X - Unity는 Component 정의된 magic method만 호출·base class virtual은 derived가 override 안 하면 호출 안 됨 - 결과: KinematicObject.OnEnable 호출 X → body=NULL·KinematicObject.FixedUpdate 호출 X → velocity 갱신 X·gravity 적용 X - Enemy 자연 낙하 X·patrol 동작 X·영구 정지 검증: - MCP Play 후 body field reflection 읽기 → NULL - Rigidbody2D 컴포넌트 자체는 GetComponent OK·OnEnable이 body 설정 안 함 fix (AnimationController): 1. Awake 영역에 base 초기화 위임: - body = GetComponent()·body.bodyType = Kinematic - contactFilter.useTriggers/SetLayerMask/useLayerMask 2. Update·FixedUpdate override 추가: - protected override void Update() { base.Update(); } - protected override void FixedUpdate() { base.FixedUpdate(); } - Unity가 AnimationController 인스턴스의 Update/FixedUpdate 호출 → base 실행 검증 후 (MCP Play): - body=OK·IsGrounded=True·자연 낙하 정합 (pos.y=-2.5 등) - Enemy 일부 발판 위 정착·일부 InfiniteHorizontalGround 영역 밖 무한 낙하 (별건) 회귀 영역 X: - spriteRenderer/animator GetComponentInChildren·field initializer 가드 영역 영역 X - KinematicObject 자체 영역 영역 X (다른 KinematicObject 상속 클래스는 별도 검증) Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Scripts/Mechanics/AnimationController.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Assets/Scripts/Mechanics/AnimationController.cs b/Assets/Scripts/Mechanics/AnimationController.cs index 0efaaaf..818bcdc 100644 --- a/Assets/Scripts/Mechanics/AnimationController.cs +++ b/Assets/Scripts/Mechanics/AnimationController.cs @@ -50,6 +50,25 @@ namespace Platformer.Mechanics if (animator == null) animator = GetComponentInChildren(); // BT12-Dev 2026-05-12 — field initializer Awake 영역 이동 (Editor·Play mode 전환 시 model 미초기화 NRE 회피). try { model = Simulation.GetModel(); } catch { model = null; } + + // BT12-Dev 2026-05-12 — KinematicObject base 영역 protected virtual OnEnable/Start/Update/FixedUpdate Unity 호출 X 정정 + // (override X·derived class만 magic method 영역). Awake 영역 base 초기화 위임. + body = GetComponent(); + if (body != null) body.bodyType = RigidbodyType2D.Kinematic; + contactFilter.useTriggers = false; + contactFilter.SetLayerMask(Physics2D.GetLayerCollisionMask(gameObject.layer)); + contactFilter.useLayerMask = true; + } + + // BT12-Dev 2026-05-12 — Update·FixedUpdate Unity 호출 정합 (override 영역 derived 영역 호출 영역) + protected override void Update() + { + base.Update(); + } + + protected override void FixedUpdate() + { + base.FixedUpdate(); } protected override void ComputeVelocity()