Scriptum/Assets/Scripts/Item/PickableController.cs

23 lines
454 B
C#
Raw Normal View History

2022-04-19 16:18:30 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-05-15 18:54:59 +02:00
public class PickableController : MonoBehaviour
2022-04-19 16:18:30 +02:00
{
2022-05-15 18:54:59 +02:00
public Item item;
public void Start()
{
item.Name = gameObject.name;
}
2022-04-19 16:18:30 +02:00
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player")
{
2022-05-15 18:54:59 +02:00
InventoryManager.Instance.AddToInventory(this.item);
2022-04-19 16:18:30 +02:00
Destroy(gameObject);
}
}
}