Projext/Assets/02_Scripts/Items/ItemGet/ItemPickUp.cs

34 lines
867 B
C#
Raw Normal View History

2026-03-01 03:22:29 +00:00
// ItemPickup.cs
using UnityEngine;
public class ItemPickup : MonoBehaviour
{
[Header("아이템 설정")]
public ItemData itemData;
[Header("획득 연출")]
public GameObject pickupEffect; // 파티클 등
public AudioClip pickupSound;
private void OnTriggerEnter(Collider other)
{
Debug.Log($"충돌 감지: {other.gameObject.name} / Tag: {other.tag}");
if (!other.CompareTag("Player"))
{
Debug.Log("플레이어 태그 불일치");
return;
}
PlayerInventory inventory = other.GetComponent<PlayerInventory>();
if (inventory == null)
{
Debug.Log("PlayerInventory 컴포넌트 없음!");
return;
}
inventory.AddItem(itemData);
Destroy(gameObject);
Debug.Log("아이템 획득 완료!");
}
}