Hello, I am trying to make a script that I can place within a 2D sprite that has a boxcollider2D within it in my 2D platformer. I have been trying to make it reload the level when the player touches the object. I have been trying this script but I can’t get it to work. What am I doing wrong?
public class Restart : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Player")
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}