Answers for "sleep unity"

C#
8

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
1

unity c# run a command then wait

IEnumerator placeholder1() // weird syntax for this but its needed.
{
  COODE HERE
    yield return new WaitForSeconds(SECONDSHERE); //this is were the wait will happen. so position it in your func where you want to wait.
  CODE HERE
} // if this returns errors its most likely because you need to include the  yield return new WaitForSeconds
// if this still return errir check that you didnt clean up the tags at the top because you need the two using System.Collections; and using System.Collections.Generic; tags. So if you got rid of them just add them back.


//now we need to call the func in a void or a public void if we want to acces it outside our script.
public void placeholder2() //this can be called using a button or another scipt etc.
{
  StartCoroutine(placeholder1())
}
Posted by: Guest on March-22-2020

C# Answers by Framework

Browse Popular Code Answers by Language