-1

When creating my project i tried to change scenes after 15 seconds by using C#

using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Changer : MonoBehaviour {
IEnumerator Wait()
{

    yield return new WaitForSeconds(15.0f);

}
// Use this for initialization
void Start () {
    Wait();
    SceneManager.LoadScene(1);
}

// Update is called once per frame
void Update () {

}
}

I run the program but instead of waiting 15 seconds it immediately changed to the next scene. If you can help me please do so. :)

1 Answers1

1

To call a coroutine (IEnumerator) you need to use StartCoroutine(Wait) ;

If you have issues with coroutines the unity docs cover the basics and you tubers like Quil18Creates have videos on the subject.

Rocketman Dan
  • 300
  • 2
  • 8