Search Unity

Invoke not waiting

Discussion in 'Documentation' started by Phoenix_Firebird, Oct 8, 2021.

  1. Phoenix_Firebird

    Phoenix_Firebird

    Joined:
    Jul 4, 2020
    Posts:
    1
    I copied a code from Brackeys that was supposed to wait before executing a function, but for some reason the Invoke function is not waiting. Both Debug.Log lines run right.

    public float restartDelay = 2.0f;
    public void EndGame()
    {

    if (gameHasEnded == false)
    {
    gameHasEnded = true;
    Debug.Log("GAME OVER");
    Invoke("Restart", restartDelay);
    Debug.Log("This should be working");
    }

    }

    Also this affects the lighting... Does the lighting problem affect the final game when I export it?
     
    Last edited: Oct 8, 2021