Did mine a little different but it appears to be having the same effect, I was actually kind of happy to figure out a different way of doing it that actually works, feels like things are starting to click (plus getting more comfortable finding what I want in the unity scripting API)
I can’t foresee any issues but if anyone can see something glaringly obvious let me know.
{
private Scene currentScene;
[SerializeField]
float loadDelay = 2f;
void Start()
{
currentScene = SceneManager.GetActiveScene();
}
void OnCollisionEnter(Collision collision)
{
switch (collision.gameObject.tag)
{
case "Friendly":
Debug.Log("Collided with a afriendly object");
break;
case "Finish":
FinishSequence();
break;
default:
Debug.Log("That was life ending");
CrashSequence();
break;
}
}
void LoadNextLevel()
{
// if there is a scene in the build index after the current scene load that one
if (currentScene.buildIndex < SceneManager.sceneCountInBuildSettings -1)
{
SceneManager.LoadScene(currentScene.buildIndex + 1);
}
// if we are on the last scene in the build index load the first scene in the build index
else if (currentScene.buildIndex == SceneManager.sceneCountInBuildSettings - 1)
{
SceneManager.LoadScene(0);
}
}