using UnityEngine; public class DoorOpenTrigger : MonoBehaviour { private DoorControl doorC; private void Awake() { doorC = GetComponentInParent<DoorControl>(); } private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player")) { ItemInventory iInv = collision.gameObject.GetComponent<ItemInventory>(); bool playerHasKey = iInv.CheckForKey(doorC.GetDoorID()); if (playerHasKey) doorC.SetDoorOpenState(true); } } }