using System.Collections; using System.Collections.Generic; using UnityEngine; /* -------------------------------------- Project: Programing assessment Standard: 91906 (AS3.7) v.1 School: Tauranga Boys' College Author: Rauputu Noah Phizacklea Date: August 2024 Unity: 2021.3.18f --------------------------------------- */ public class KeyPickup : MonoBehaviour { public string keyID; // Unique identifier for the key private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { Inventory inventory = other.GetComponent(); if (inventory != null) { inventory.AddKey(keyID); // Add the key to the inventory Destroy(gameObject); // Remove the key object from the scene } } } }