I did follow other post which I need to make an array for audio source, but for some reason, it’s only playing array [0].
below is my code:
AudioSource lowHPSE; //SE = Sound Effect
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 ();
}
}
right now, when conditions are met, it’s only playing sound for lowHPSE. The audio source orders in inspector is lowHPSE, then lowAmmoSE.
How do I play lowAmmoSE, the second audio source?