In my game I would like to restart the scene once my player loses his health, so far he dies and the particle effects show but the scene doesn't restart. Could someone show me what I am doing wrong, thank you!
void Die()
{
Instantiate(playerDeath, transform.position, Quaternion.identity);
Destroy(gameObject);
}
private void Update()
{
if (curHealth > maxHealth)
{
curHealth = maxHealth;
}
if (curHealth <= 0)
{
Die();
StartCoroutine(ReloadScene());
}
}
IEnumerator ReloadScene()
{
yield return new WaitForSeconds(1.5f);
SceneManager.LoadScene("1");
}
↧