Project_Boost Invoke delay does not work please help!

Edit: fixed now. you have to delete SceneManger.LoadScene(1) and SceneManger.LoadScene(0).

  void OnCollisionEnter(Collision collision)
    {
        switch (collision.gameObject.tag)
        {
            case "Friendly":
                break;
            case "Finish":
                state = State.Transcending;
                Invoke("LoadNextLevel", 1f); // paramertize time
                SceneManager.LoadScene(1);   <----- delete this
                break;
            default:
                state = State.Dying;
                Invoke("LoadFirstLevel", 1f);
                SceneManager.LoadScene(0);   <------- delete this
                break;
        }
    }

Hi Mr_Privacy,

Welcome to our community! :slight_smile:

Directly after Invoke, LoadScene gets called. Invoke does not pause the code. It just invokes a method with a delay. Remove the lines with LoadScene from the switch.

Remember you can also look at the lecture code changes via the link in the Resources of each lecture.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms