using UnityEngine; public class KeyPickup : MonoBehaviour { void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { Debug.Log("Key collected!"); KeyManager.hasKey = true; Destroy(gameObject); // Remove the key from the scene } } }