Question by
markdolan2203 · Nov 16, 2019 at 08:59 PM ·
scene-loadingdelayscene-switching
,delay after dying and going back to main menu (new scene)
i want a delay after dying and then change scene
this is my game manager script
using UnityEngine; using UnityEngine.SceneManagement; public class gamemanager : MonoBehaviour {
bool gamehasended = false;
public float restartdelay = 1f;
public void endgame ()
{
if (gamehasended == false)
{
gamehasended = true;
Debug.Log("GAME OVER");
Invoke("restart", restartdelay);
}
}
void restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
},i want to die in the game and then wait a second or so and then change scene
this is my gamemanager script
using UnityEngine; using UnityEngine.SceneManagement; public class gamemanager : MonoBehaviour {
bool gamehasended = false;
public float restartdelay = 1f;
public void endgame ()
{
if (gamehasended == false)
{
gamehasended = true;
Debug.Log("GAME OVER");
Invoke("restart", restartdelay);
}
}
void restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
Comment
And? What is your question exactly? What problem are you facing? Is Debug.Log
called?