IEnumerator SetupBattle() { //set up enemy and enemy AI // GameObject enemyGO = Instantiate(enemyPrefab); GameObject enemyGO = enemyPrefab; enemy = enemyGO.GetComponent <NPC>(); enemyAI = enemyGO.GetComponent <NPCAI>(); //display starting message dialogueBox.gameObject.SetActive(true); dialogueText.text = "A monster approaches."; //set HUDs enemyHUD.SetEnemyHUD(enemy); playerHUD.SetPlayerHUD(); yield return(new WaitForSeconds(2f)); dialogueText.text = "What will you do?"; yield return(new WaitForSeconds(2f)); dialogueBox.gameObject.SetActive(false); //start the battle, move to player turn state = BattleState.PLAYERTURN; PlayerTurn(); }