I saw some similar questions but literally I can't see where I'm doing wrong. Basicly I need a break before level fail.
public static int point;
public static int health;
void Awake()
{
point = 0;
health = 3;
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "coin")
{
point ++;
EventManager.OnCoinPickUp.Invoke();
Coin.SharedInstance.DisposeOnTrigger(other);
}
else if(other.gameObject.tag == "Obstacle")
{
health --;
EventManager.OnPreLevelFail.Invoke();
if(health == 0)
{
StartCoroutine(WaitBeforeFail());
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}
IEnumerator WaitBeforeFail()
{
yield return new WaitForSeconds( 1.5f );
EventManager.OnLevelFail.Invoke();
}
It doesn't work so I would appreciate some help.