diff --git a/Assets/Scripts/Gameplay/EnemyDeath.cs b/Assets/Scripts/Gameplay/EnemyDeath.cs
index db96405..89da4da 100644
--- a/Assets/Scripts/Gameplay/EnemyDeath.cs
+++ b/Assets/Scripts/Gameplay/EnemyDeath.cs
@@ -1,22 +1,36 @@
using Platformer.Core;
using Platformer.Mechanics;
+using UnityEngine;
namespace Platformer.Gameplay
{
///
/// Fired when the health component on an enemy has a hitpoint value of 0.
+ /// BT104 (PD 명시 2026-05-08): Enemy 사망 시 patrol·시각 영역 비활성 + 1초 후 GameObject Destroy
///
- ///
public class EnemyDeath : Simulation.Event
{
public EnemyController enemy;
public override void Execute()
{
- enemy._collider.enabled = false;
- enemy.control.enabled = false;
- if (enemy._audio && enemy.ouch)
+ if (enemy == null) return;
+
+ // 충돌·이동·patrol 영역 비활성
+ if (enemy._collider != null) enemy._collider.enabled = false;
+ if (enemy.control != null) enemy.control.enabled = false;
+ enemy.enabled = false; // BT104: EnemyController patrol 영역 정지
+
+ // death 애니메이션 트리거 (Enemy.controller 영역의 'death' parameter)
+ var animator = enemy.GetComponent();
+ if (animator != null) animator.SetTrigger("death");
+
+ // 사운드
+ if (enemy._audio != null && enemy.ouch != null)
enemy._audio.PlayOneShot(enemy.ouch);
+
+ // 1초 후 GameObject 영역 Destroy (사망 애니메이션 시간)
+ Object.Destroy(enemy.gameObject, 1f);
}
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Mechanics/EnemyController.cs b/Assets/Scripts/Mechanics/EnemyController.cs
index 7baec92..1cd215d 100644
--- a/Assets/Scripts/Mechanics/EnemyController.cs
+++ b/Assets/Scripts/Mechanics/EnemyController.cs
@@ -102,8 +102,41 @@ namespace Platformer.Mechanics
}
// BT97 — Start 시점 안전 거리 측정 (AutoForeground Tile data 활성 후·AfterSceneLoad 이후)
+ // BT104 — 시작 위치 발판 검증·자동 재배치 (PD가 PD Foreground·빈 영역 배치 시 가까운 발판 영역으로 이동)
void Start()
{
+ if (_collider != null)
+ {
+ Vector2 footHere = new Vector2(_collider.bounds.center.x, _collider.bounds.min.y + 0.05f);
+ RaycastHit2D groundUnder = Physics2D.Raycast(footHere, Vector2.down, cliffCheckDepth, groundLayerMask);
+ if (groundUnder.collider == null)
+ {
+ // 시작 위치 발판 X — 가까운 좌·우 발판 자동 검색
+ for (float d = 0.5f; d <= 50f; d += 0.5f)
+ {
+ Vector2 rightProbe = new Vector2(_startX + d, footHere.y);
+ if (Physics2D.Raycast(rightProbe, Vector2.down, cliffCheckDepth, groundLayerMask).collider != null)
+ {
+ _startX += d;
+ Vector3 newPos = new Vector3(_startX, transform.position.y, transform.position.z);
+ transform.position = newPos;
+ if (_body != null) _body.position = newPos;
+ break;
+ }
+ Vector2 leftProbe = new Vector2(_startX - d, footHere.y);
+ if (Physics2D.Raycast(leftProbe, Vector2.down, cliffCheckDepth, groundLayerMask).collider != null)
+ {
+ _startX -= d;
+ Vector3 newPos = new Vector3(_startX, transform.position.y, transform.position.z);
+ transform.position = newPos;
+ if (_body != null) _body.position = newPos;
+ break;
+ }
+ }
+ }
+ }
+ _startY = transform.position.y; // 재배치 후 _startY 갱신
+
_maxRightRange = MeasureSafeWalkDistance(1f);
_maxLeftRange = MeasureSafeWalkDistance(-1f);
SetNextPatrolTarget();