public IEnumerator enemyStrike() { if (isRwKeepBoss) //If the player is near the first boss, perform the following. { GetComponent <BoxCollider2D>().enabled = false; //Deactivate the weak area of the boss when the boss attacks. } enemyAnim.SetBool("isAttacking", true); yield return(new WaitForSeconds(0.02f)); //Give the animation some time. wBoxEnemy.SetActive(true); yield return(new WaitForSeconds(0.14f)); //Give the animation some time, and give the weapon box some time to catch the player. if (Physics2D.IsTouching(wBoxEnemy.GetComponent <BoxCollider2D>(), playerPrefab.GetComponent <PolygonCollider2D>())) //If the enemy's sword connects with the player's collider, perform the following. { wBoxEnemy.SetActive(false); //Don't kill the player multiple times. playerNlg.hasBeenStabbed = true; respawnScript.killPlayer(); //Kill the player. } wBoxEnemy.SetActive(false); //Deactivate the enemy's weapon box once the enemy's finished attacking. enemyAnim.SetBool("isAttacking", false); if (isRwKeepBoss) //If the player is near the first boss, perform the following. { GetComponent <BoxCollider2D>().enabled = true; //Reactivate the weak area when the boss is no longer attacking. } }