I am making a 2d game in Unity and I have 2 Levels so far and it works but when I add a 3rd scene (Level) into the build settings, I can only play Level 1 over and over again. When I remove Level 3, I can play Level 1 and 2.
Here is the code for my finish line
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class FinishLine : MonoBehaviour
{
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag =="Player")
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}