IEnumerator KillEnemy(GameObject col) { if (col.GetComponent <Rigidbody2D>() != null) { Destroy(col.GetComponent <Rigidbody2D>()); } if (col.GetComponent <BoxCollider2D>() != null) { Destroy(col.GetComponent <BoxCollider2D>()); } FieldGenerator.ChEnemy("Enemies: " + (GameObject.FindGameObjectsWithTag("Enemy").Length - 1)); FieldGenerator.ChScore(100); col.gameObject.GetComponent <Animator>().SetBool("IsDead", true); yield return(new WaitForSeconds(0.1f)); Destroy(col); }