Invoke code not working / no delay

Hello, I checked over my code to make sure it matched the lecture, and VS tells me everything is okay, yet when I press play there is not delay after the finish line. Is there something wrong or could I have possibly missed a step? Here is my code:
ā€œā€"
using UnityEngine.SceneManagement;

public class FinishLine : MonoBehaviour
{

void OnTriggerEnter2D(Collider2D other)
{
    if (other.tag == "Player")
    {
        Invoke("ReloadScene", .5f);
    }
}

void ReloadScene()
{
    SceneManager.LoadScene(0);
}

ā€œā€"

It all looks fine except that you are delaying half a second, which is near-immediate. In the lecture, Rick used 2 seconds before changing it to a serialised field, and it defaults to 1 second after he did that.

So I changed it from half a second to 2 seconds but it still does not delay.

Then I think something else is also triggering a scene reload. Find all the places that you are using SceneManager.LoadScene(0) and make sure none of these could also be triggering

1 Like

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

Privacy & Terms