public void OnTriggerExit(Collider other) { Coal component = other.gameObject.GetComponent <Coal>(); if (component != null) { boiler.RemoveCoal(component); } Flame component2 = other.gameObject.GetComponent <Flame>(); if (component2 != null) { boiler.RemoveFlame(component2); } }