Can someone tell me how to restart the scene if my player hits two objects

So I have a game where a 2d spaceship is flying through a cave and I need it so that once I hit an object the level restarts It would be great if someone could tell me how to do this. thanks.

here:

void OnCollisionEnter2D (Collision2D other) {
        if(other.gameObject.tag == "Player")
        {
            Application.LoadLevel(Application.loadedLevel);
        }
	}

put this on your object that gets hit. on its collider2d, make sure the ‘Trigger’ checkbox is ticked. also make sure your player has the tag ‘Player’. here is how you do that in the inspector tab:

https://docs.unity3d.com/uploads/Main/TagDropdown.png

You can use SceneLoader.LoadScene () to simply reload the level, though, performance wise, I would advise to simply reset objects and data to their original states.

  • store/reset objects’ transforms and states
  • destroy every object that was instantiated, or deactivate every pooled object that were activated