Hello, Can somebody tell me what im doing wrong with this script, im clueless and can not get this WaitForSeconds to work. I want it to wait 3 seconds before it goes back to my main menu, the error at the moment says: The name ‘yield’ does not exist in the current context. this is the script
using UnityEngine;
using System.Collections;
public class endRace : MonoBehaviour {
private startRace race;
public GameObject GameOver;
public float WaitForSeconds;
// Use this for initialization
void Start () {
race = FindObjectOfType(typeof(startRace)) as startRace;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider raceTrig)
{
//Stops timer and ends race
if(raceTrig.gameObject.tag == "Player")
{
race.raceStarted = false;
GameObject.Instantiate(GameOver);
yield.WaitForSeconds(3); //wait 3 seconds
Application.LoadLevel("mainmenu"); //then return to main menu
}
}
}