I am trying to use WaitForSeconds at the end of a level, but the line after yield WaitForSeconds is never executed. I have tried calling end level with StartCoroutine(endLevel) but that made no difference.
function OnTriggerEnter (hit: Collider) {
if (hit.gameObject.tag == "wormProjectile")
{
Destroy(hit.gameObject);
var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
Destroy(gameObject);
num_cannon=num_cannon-1;
if (num_cannon<=0)
{
endLevel();
}
}
}
function endLevel()
{
TextMsgControl.message = "Level Complete";
WaitForSeconds(5);
TextMsgControl.message = "Game Over";
}
Any help appreciated.