I’m trying to make a little game based off the Roll-A-Ball tutorial game, and I want to make it so that once you’ve collected all the cubes, the game waits 4 seconds and then starts the next scene/level. However, the waitforseconds command just refuses to work. This is the code I’m using:
void SetCountText ()
{
countText.text = "Count: " + count.ToString();
if (count >= 12)
{
winText.text = "YOU WIN!";
winSound.GetComponent<AudioSource>().Play ();
yield return new WaitForSeconds(4);
SceneManager.LoadScene("Level2");
}
}
When I run the debug it says that ‘void is not an iterator block’, which I don’t know what it means. The Scripting API appears to say that the ‘IEnumerator’ command has to be in place of the void command, but when I do that it doesn’t work at all either. Some other questions I’ve found say that you have to use a ‘Coroutine’ command, which the Scripting API doesn’t say anything useful about other than having the ‘IEnumerator’ in the example code. Why can’t I just use the WaitForSeconds command normally?