Advertisement
FlyingFrog

Item

Dec 26th, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Item : MonoBehaviour
  4. {
  5.     [SerializeField] private string _itemName;
  6.     public string ItemName => _itemName;
  7.  
  8.     private void OnTriggerEnter(Collider other)
  9.     {
  10.         if(other.TryGetComponent(out PlayerInventory inventory))
  11.         {
  12.             inventory.AddItem(this);
  13.             Destroy(gameObject);
  14.         }
  15.     }
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement