Question by
sabertastic · Feb 25, 2017 at 04:36 AM ·
scene-loadingwaitforsecondsienumerator
LoadScene not working in IEnumerator?
"SceneManager.LoadScene("StartMenu");" works if I put it right under " Instantiate(deathcamera);" but for some reason it doesn't work in IEnumerator. Why is it not working?
void OnCollisionEnter2D(Collision2D other)
{
if(other.gameObject.tag == "GROUND")
{
Jumping = false;
anim.SetInteger("State", 0);
}
if (other.gameObject.tag == "DEATH")
{
Destroy(gameObject);
Instantiate(deathscreen);
Instantiate(deathcamera);
StartCoroutine(DeathWait());
}
}
IEnumerator DeathWait()
{
yield return new WaitForSeconds(3);
SceneManager.LoadScene("StartMenu");
}
Comment