Home > Enterprise >  Invoke isn't delaying?
Invoke isn't delaying?

Time:11-15

Here is the target code with the Invoke call: image

Here is the player code: Image

I have also tried without the nameof statement but it doesnt work.

CodePudding user response:

Instead of Invoke() you can use Coroutines to create some delay like the following:

void OnTriggerEnter2D(Collider2D other)
{
    if(other.tag == "Player")
    {
       StartCoroutine(ReloadScene());
    }
}

IEnumerator ReloadScene()
{
    yield return new WaitForSeconds(FinishDelay);
    SceneManager.ReloadScene(0);
}

CodePudding user response:

make sure all the changes are synced with unity, click on the script in unity and see if the preview is the same as in VS. if it isn't just reopen unity.

  • Related