I have an object with a script on it called SafeZone. I want this script to return true when entered by the player tagged game object. so I did:
Then on my ManagerScript I want to check the Boolean from SafeZone and load a new scene when its true.
I have a reference to the SafeZone script on my ManagerScript by making the gameobject a prefab and setting it in the editor via the inspector.
I set up my levels by giving them a curLevel and nextLevel name and set them to the name needed to access the next level in the build. It works when on the zone itself. SceneManager.Loadscene(nextScene.name);
nothing works. I made sure CheckSafe(); is called from update method I also added a debug line to the function and it doesn’t get output to the console window either. However, the boolean on the game object will still toggle when the player object enters it. It just isn’t sending that value to the GameManager script. At the moment I kept it on the SafeZone gameObject and it loads the next scene just fine, but I don’t know if this is the best way to do this. Can anyone tell me what i’m doing wrong?
The reason I want to keep it all on the GameManager is I also have a public int for lives on the script as well, and a deathzone. I want to reset the level, not reload which is another beast I’m working on implementing, and decrease the lives value by 1. Same deal with the script an OTE that checks for the player on a separate game object. That when entered should return the boolean entered as true, and decrease the lives value by one or lives–; and reset the level function Reset();
so something like
CheckDeath(){
if (DeathZone.entered == true)
{ lives–;
Reset();}}