Answers for "unity3d coroutine to do for n seconds"

C#
7

wait time in unity

using System.Collections;

private void Start()
{
	StartCoroutine(Wait());
}

IEnumerator Wait()
{
	//To wait, type this:
  
  	//Stuff before waiting
	yield return new WaitForSeconds(/*number of seconds*/);
  	//Stuff after waiting.
}
Posted by: Guest on July-12-2020
6

waitforseconds unity

public void GameOver()
		{
			//Set levelText to display number of levels passed and game over message
			levelText.text = "After " + level + " months, you starved.";

			new WaitForSeconds(6);

			Application.Quit();


		}
Posted by: Guest on June-05-2020
0

unity3d coroutine to do for n seconds

StartCoroutine(GoLeft()); 
 
IEnumerator GoLeft() {     
float timePassed = 0;     
    while (timePassed < 3){

    timePassed += Time.deltaTime;
    yield return null;     
    } 
}
Posted by: Guest on November-29-2020

C# Answers by Framework

Browse Popular Code Answers by Language