private void OnTriggerEnter2D(Collider2D collision) { InteractableCharacter npc = collision.GetComponent <InteractableCharacter>(); if (null != npc) { _InteractableNPC = npc; _InteractableNPC.OnPlayerTriggered(true); } InteractableItem item = collision.GetComponent <InteractableItem>(); if (null != item) { _InteractableItem = item; _InteractableItem.OnPlayerTriggered(true); } }
private void OnTriggerExit2D(Collider2D collision) { InteractableCharacter npc = collision.GetComponent <InteractableCharacter>(); if (npc == _InteractableNPC && null != _InteractableNPC) { _InteractableNPC.StopInteracting(); _InteractableNPC.OnPlayerTriggered(false); _InteractableNPC = null; return; } InteractableItem item = collision.GetComponent <InteractableItem>(); if (item == _InteractableItem && null != _InteractableItem) { _InteractableItem.OnPlayerTriggered(false); _InteractableItem = null; return; } }