If scene just started wait 3 second before proceeding in the script.

Hi
I would like some help with a short part of Scripting
First of im sorry for the simple question but I am new and cant get this to work.

I am trying to put out in C# the code : If scene just started than wait 3 seconds before proceeding in the script.

I got everything else coming after but I really want this script to give the player some time to react at the begining of a scene.

I found this to begin with but cant find how to put it properly toguether

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour
{
void OnLevelWasLoaded(int Level1) { //error comes up in this line

	yield return new WaitForSeconds(3);
	
}
void OnTriggerEnter (Collider col)
{
	if(col.gameObject.name == "Trigger1")
	{
			Application.LoadLevel("RPG");
	}
}

}

finaly here is the error I get and I dont understand it :S

Assets/Test.cs(6,14): error CS1624: The body of Test.OnLevelWasLoaded(int)' cannot be an iterator block because void’ is not an iterator interface type

Thx for the help :stuck_out_tongue:

You can’t do that. Not all functions can have a yield in them, it’s not really worth explaining why right now…

Instead, do this:

 Invoke ("LateStart", 3.0);

Then put all your delayed startup stuff in LateStart().