public void OnTriggerEnter(Collider other) { Coal component = other.gameObject.GetComponent <Coal>(); if (component != null) { boiler.AddCoal(component); } Flame component2 = other.gameObject.GetComponent <Flame>(); if (component2 != null) { boiler.AddFlame(component2); } }