using UnityEngine; public class ItemPickups : MonoBehaviour { void OnTriggerEnter2D(Collider2D other) //Activate when the player walks over the item { if (other.tag == "Player") { PlayerInventory inventory = other.GetComponent(); //Acces the PlayerInventory script string itemTag = gameObject.tag.ToLower(); if (gameObject.tag == "wood") //If picking up wood { inventory.AddItem(itemTag); // Add to player's inventory Destroy(gameObject); } if (gameObject.tag == "gold") //If picking up gold { inventory.AddItem(itemTag); Destroy(gameObject); } if (gameObject.tag == "meat") //If picking up meat { inventory.AddItem(itemTag); Destroy(gameObject); } } } }