When my player dies I stop the game music that’s attached to a game object with an audio source. I then play the “game over” music which is activated through the audio source on my player. I’m just starting out w/ audio in unity so I’m hoping this is just an easy fix. Currently none of my audio commands (audio.volume, audio.loop, audio.panLevel) work… and i’m not sure why. I just want the “game over” music to play one time at a lower volume level. currently it’s playing at max volume and keeps looping. Any help to fix this is appreciated. Thanks!
if (currentLife == 0){
GetComponent(EnemyDestroyPlayer).enabled = false;
Time.timeScale = 0.0001;
gameMusic.active = false;
if(!audio.isPlaying) {
audio.clip = playerDeath;
audio.Play();
audio.loop = false;
audio.volume = 0.1;
audio.panLevel = 0.0;
}
player.animation["Die"].wrapMode = WrapMode.ClampForever;
player.animation.Play("Die");
player.animation["Die"].speed = 1.0/Time.timeScale;
yield WaitForSeconds(5.0 * Time.timeScale);
Camera.main.GetComponent(GameManager).SetGameOver();
}