My character has a reset on death script.
I would like to call a Global event "You Died"
However, I am not sure how to do this could someone help?
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace XXX-XX
{
/// <summary>
/// Reset the level on character's death.
/// </summary>
public class ResetOnDeath : MonoBehaviour, ICharacterHealthListener
{
/// <summary>
/// Time in seconds to reset the level after character's death
/// </summary>
[Tooltip("Time in seconds to reset the level after character's death")]
public float Delay = 3.0f;
/// <summary>
/// Starts a sequence to reset the level after waiting for Delay.
/// </summary>
public void OnDead()
{
StartCoroutine(delayedReset());
}
public void OnResurrect() { }
private IEnumerator delayedReset()
{
yield return new WaitForSeconds(Delay);
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
private void OnValidate()
{
Delay = Mathf.Max(0, Delay);
}
}
}
I have come to see that this is not the correct approach, but thanks anyway.