Wait a second before enemy move

I am trying to get the enemies in my game to each wait a second before taking their turns. This is the code I have so far:

			StartCoroutine ("WaitOneSecond");

			if (enemyArray [turnNumber] != null) {
				TestEnemyStats estats = (TestEnemyStats)enemyArray [turnNumber].GetComponent (typeof(TestEnemyStats));
				int rand = Random.Range (0, playerArray.Length);
				estats.BasicAttack (playerArray [rand]);
			}
				

			if (turnNumber >= enemyArray.Length - 1) {
				turnNumber = 0;
				turnSide = Turns.Player;
			} else {
				turnNumber++;
			}

And the coroutine is as such:

	IEnumerator WaitOneSecond()
	{
		yield return new WaitForSecondsRealtime (1);
	}

The enemies are not waiting at all. I also tried putting the entire enemy turn in a coroutine, to the same lack of effect. I know I’m doing something wrong, but I have no idea what it is. Thanks!

Only code that is after the yield in the IEnumerator is executed after a second. You don’t currently have anything there. The code that is executed after the wait has to be inside the coroutine.

Make sure that StartCoroutine is not called multiple times when waiting for the enemy turn. e.g. make a field bool waiting, only start the coroutine if waiting == false, set waiting to true when calling StartCoroutine and set to false at the end of the coroutine. Or you can set the turnSide to something else than Player or Enemy during the wait.