2026-06-01 씬전환시 무기 사라지는 현상 수정

This commit is contained in:
2026-06-01 13:06:31 +09:00
parent 964383c59c
commit 11a6a4f983
7 changed files with 67 additions and 13 deletions

View File

@@ -150,10 +150,9 @@ private void Awake()
// 공격이 enemy를 hit하면 _lastHitEnemy를 기억 → 다음 잡기에서 그 enemy를 우선 타겟팅.
_attackHitbox.OnHit += OnAttackHit;
// 무기 인벤토리: 같은 GameObject에 컴포넌트가 없으면 자동 부착.
_weaponInventory = GetComponent<PlayerWeaponInventory>();
if (_weaponInventory == null)
_weaponInventory = gameObject.AddComponent<PlayerWeaponInventory>();
// 무기 인벤토리: 영속 싱글톤 (DontDestroyOnLoad). 없으면 EnsureInstance가 새로 생성.
// 씬 전환 시 PlayerController는 파괴되지만 인벤토리는 살아남아 무기 목록을 유지한다.
_weaponInventory = PlayerWeaponInventory.EnsureInstance();
_weaponInventory.OnWeaponChanged += OnWeaponChanged;
}