Wrong Scene Loading On Change
I have 8 levels and in each level i have atrigger to move onto an intermediate whch shows the player their score for that level. They can pres next to go to next level. For level 1 whn you finsih intermediate1 will open and shows you the score. For level2 intermediate2 opens and shows you your score same for 3. But for 4,5,6,7 and 8. The intermediate1 will open rather than the corresponding one. However, if i remove intermediate1 from the build settings then intermediate 6 for example will load for level 6 rather than intermedaite 1. Code For Trigger In Level1
using UnityEngine.SceneManagement; using System.Collections; using UnityEngine;
public class EndTrigger1 : MonoBehaviour {
//this is the function which reacts to a colision from an object
private void OnTriggerEnter()
{
//here a function is being used to look at the created sceness.
//Each scene has an idex.
//On collision the index is implemented by one and the function fetches the new scene with that index and plays it.
SceneManager.LoadScene("Intermediate1");
}
}
Code For Trigger In Level6
using UnityEngine.SceneManagement; using System.Collections; using UnityEngine;
public class EndTrigger6 : MonoBehaviour {
//this is the function which reacts to a colision from an object
private void OnTriggerEnter(Collider other)
{
//here a function is being used to look at the created sceness.
//Each scene has an idex.
//On collision the index is implemented by one and the function fetches the new scene with that index and plays it.
SceneManager.LoadScene("Intermediate6");
}
}
Everything looks right in the build settings but i don't why intermediate 1 loads when the player hits the trigger in level 6. If you could help i would really appreciate your time.,So I am making a game and when a box is hit it is used as a trigger and loads an intermediate scene which will show the player their score. Levels 1 to and 3 work finr but the others dont. When you complete level 1 it loads the scene which shows the level 1 score however when you complete level 6 it again loads the level 1 intermediate.
Not sure if it's the same problem but when I had a similar issue it was caused by a different LoadScene() being triggered elsewhere in my code. Try doing a search for other instances of LoadScene() in your project, they may be getting called before the intended one.
Answer by WolverineLight · May 27 at 03:22 PM
Hello alf1ew4rd2832,
Are you sure you have the right script attached to the trigger in the intermediate6 scene? That is my best guess - you likely duplicated something but forgot to change your script(s).