Files
BABA_YAGA/Assets/Scripts/TreasureItem.cs
2026-06-02 23:14:19 +07:00

18 lines
572 B
C#

using UnityEngine;
public class TreasureItem : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
// Kiểm tra xem thứ chạm vào có script PlayerInventory không
PlayerInventory player = other.GetComponentInParent<PlayerInventory>();
if (player != null && !player.hasTreasure)
{
player.hasTreasure = true;
Debug.Log("Đã nhặt kho báu!");
// Làm vật phẩm biến mất
gameObject.SetActive(false); // Hoặc Destroy(gameObject);
}
}
}