My Invoke method does not Work


even if i use Invoke(nameof(ReloadScene), delay); it does not work
When i play

Console said ReloadScene couldn’t be called
i dont know why it happened to me

my unity version is 20.3.31f1

try putting the ReloadScene() method outside the OnTriggerEnter2D method (but still in the class), so

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

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

OMG It works excellent
Thank you :slight_smile:

1 Like

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

Privacy & Terms