public void Despawn(GameObject obj) { IDestroySelf destructibleObject = obj.GetComponent <IDestroySelf>(); if (destructibleObject != null) { destructibleObject.DestroySelf(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Enemy") { IDestroySelf destructibleEnemy = other.GetComponent <IDestroySelf>(); if (destructibleEnemy != null) { destructibleEnemy.DestroySelf(); } } }