I tried to make my LoadGameOverScene()
a coroutine and called it when player dies. I used a print statement to check weather coroutine is being called or not and i found that only the statement written above yield return
are working, below ones are not, becaz of which my GameOver scene is not loading
Here’s my coroutine in Levels
script-
public IEnumerator LoadGameOverScene()
{
print("Couritine started"); //just to check
yield return new WaitForSeconds(timeGap);
SceneManager.LoadScene("Game Over");
}
And my Player script-
// player's death
if (health <= 0)
{
Destroy(gameObject);
AudioSource.PlayClipAtPoint(playerDeathSFX,
gameCamera.transform.position, playerDeathVolume);
StartCoroutine(FindObjectOfType<Levels>().LoadGameOverScene()); //is it correct to write like this?
}
Plz help with it!