i’m making game in unity and i’m trying to make a respawn menu,but it’s not loading the level, i’ve already done a singleton for keeping variables, here’s the code:
public class lastlevel : MonoBehaviour {
public static Scene scene;
public static Scene oldscene;
// Use this for initialization
void Start() {
oldscene = scene;
scene = SceneManager.GetActiveScene();
}
// Update is called once per frame
void Update () {
}
public class respawn : MonoBehaviour {
private Scene localscene = lastlevel.oldscene;
private void Start()
{
}
void OnCollisionEnter(Collision theCollision)
{ //Unity's built in collision function
if (theCollision.gameObject.name == "resp")
{ //if the collision is called Whatever you called that cube I asked you to make
SceneManager.LoadScene(localscene.name); //this loads your game over scene. Make sure you put that scene in the build settings
print(localscene.name);
};
}
}