BGJ-2022.1/Assets/Scripts/Player/Death.cs

20 lines
503 B
C#

using Level;
using UnityEngine;
namespace Player
{
public class Death : MonoBehaviour
{
private AudioSource audioSource = null;
private void Start() => audioSource = GetComponent<AudioSource>();
public void Die()
{
LevelManager.Instance.CurrentLevel.Restart();
// Playing it after the restart because when the player gets deactivated the sound stops so it doesn't play the sound at all
audioSource.Play();
}
}
}