Im working on an endless runner game and i encountered a problem with my “restart / try again” system.
Basically, when the player dies, the “GameOver” menu appears, along with the “try again” button that should reset the scene and make the player start all over again. However, after calling SceneManager. LoadScene() I wanted to disable the “MainMenu Panel” too, as I don’t want the player to see the main menu every time he dies, but it seems that my function ignore everything after .LoadScene() is called.
here is the code :
public GameObject MenuPanel;
public GameObject ScorText;
public void Restart()
{
SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
// MenuPanel is always active at the start of the game. It is set to inactive once Play button is pressed.
MenuPanel.SetActive(false);
ScorText.SetActive(true);
}
How can i solve it ?
,