using UnityEngine;
using System.Collections;
public class UIsoundEffect : MonoBehaviour {
PlayerHP health;
Ammo ammoSE; //SE = Sound Effect
AudioSource lowHPSE;
AudioSource lowAmmoSE;
void Start() {
AudioSource[] audios = GetComponents<AudioSource> ();
lowHPSE = audios [0];
lowAmmoSE = audios [1];
}
void Update () {
AlmostDead ();
lowAmmoLeft ();
}
void AlmostDead () {
if (health.currentHP == health.healthCritical) {
lowHPSE.Play ();
}
}
void lowAmmoLeft () {
if (ammoSE.currentAmmo == ammoSE.ammoLow) {
lowAmmoSE.Play ();
}
}
}
This worked perfectly fine until a few days ago (except not playing second audio). But now, for some reason, it doesn’t play at all. I didn’t even touch anything. I saved it a few days ago, closed the project, re-opened it today, and it’s not working. Console says object null reference, but when it was working a few days ago, it said same thing, yet it still worked.
I’m going crazy here. Why is it not working? I considered recreating entire scene but I’ve come too far to re-do everything.