I have two Audio Sources on my Player. One is the audio source from the fps controller and another is a heartbeat sound that is supposed to play when the player gets below a certain health. The heartbeat will play if I play it in the start function, but won’t play if I place it in an if statement during the update function.
private AudioSource[] audioSource;
private AudioSource heartbeat;
void Start () {
//audioSource = GetComponent<AudioSource>();
audioSource = GetComponents<AudioSource>();
heartbeat = audioSource[1];
}
void Update () {
if(health <= 25)
{
Debug.Log("Beating");
heartbeat.Play();
}
Debug.Log(health);
}