Ok, so I did the research and I thought I was doing it correctly but apparently not so I need help xD I know its a very noobish question but I am trying to change from one lvl(scene) to another I currently have
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelControl : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
if (other.CompareTag(“Player”))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}
I have a trigger at the end of each lvl to go to next scene, it works going from lvl 1 to lvl 2 but nothing further, I thought I wrote it correctly by calling on the active seen number, and then adding 1 to the build index… any help would be greatly appreciated =D
Hi,
What happens when you hit the trigger at the end of level 2 ?
And how do you store your buildIndex ? Maybe include a Debug.Log(buildIndex) in your Start() to see if it counts correctly.
Simon
it seems to not even be triggering in level 2 not getting anything in the debug… not sure exactly what I’m doing xD like I said I’m really new haha but would love to get the hang of it, I appreciate your response it alone gave me a bunch of stuff to look up and try to learn, haven’t figured it out yet though. Anyone to take the time out of their day to help a total stranger is awesome=D
also I have debugged the scene name and scene index they seem to be working just fine
Just another guess : Where is your script attached and is this GameObject in the new scene as well ?
It is attached to 3d object cube, that is set to trigger, I copied the same block to level 2 by making it a prefab. It works in level 1 but not level 2. I am currently basically starting over with the whole game manager thing I had to of missed something that I learned in a tutorial somewhere. Doesn’t seem it should be complicated nor that it shouldn’t work if it works just fine on level 1 and is reading the index correctly
The idea itself is correct. You increment the level number and call scene manager for next one. If you not getting anything in the debug, then your script has not been called. The error should be not here, but in the place where you invoke that script.
I’m not sure where exactly I went wrong but got it figured out now. I appreciate the help =D I decided to start from scratch and write cleaner and more organized code and everything worked this time
I tried to look back through the code and couldn’t diagnose what was causing it sadly