private void OnTriggerExit2D(Collider2D other) { if (other.tag == "Lever" && m_lever != null) { m_lever.ChangeMaterial(); m_nearLever = false; m_lever = null; } if (other.tag == "Chest" && m_chest != null) { m_chest.ChangeMaterial(); m_nearChest = false; m_chest = null; } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Lever" && !m_nearLever) { m_nearLever = true; m_lever = other.GetComponent <LeverInteraction>(); m_lever.ChangeMaterial(); } if (other.tag == "Chest" && !m_nearChest) { m_nearChest = true; m_chest = other.GetComponent <ChestInteraction>(); m_chest.ChangeMaterial(); } }