I need to delay load level by a few second. This is the script I need to use:
public class GameRestart : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Finish") {
Application.LoadLevel ("SchoolIsland");
}
}
}
Use Invoke to delay a script execution by X seconds.
if(other.gameObject.tag == "Finish") {
Invoke( "ChangeLevel", 3.0f );
}
void ChangeLevel() {
Application.LoadLevel ("SchoolIsland");
}
void OnTriggerEnter(Collider other) {
if (other.gameObject.tag == “Finish”) {
StartCoroutine(LoadLevel(“SchoolIsland”, 5f));
}
}
IEnumerator LoadLevel( string _name, float _delay) {
yield return new WaitForSeconds(_delay);
Application.LoadLevel(_name);
}