Hi guys,
I want to lower the volume of the background music while another sound clip plays and then get the background music to its original volume. I have two scripts - one on the object being destroyed and another on a script attached to the player.
Right now, I get the volume to go to 0, but it never goes back up. Basically, nothing is happening after the yield statement. What am I missing here?
thanks!
----Script on object
var heartRotation : int = 30;
var heartSound : AudioClip;
var audioSource : AudioSource;
function OnTriggerEnter()
{
ScriptGUI.cHearts += 1; //Update collected hearts
//Lower zone music volume
ScriptGUI.fnLowerMusic();
//Play heart sound
audioSource = gameObject.Find("SFX_Heart").GetComponent("AudioSource");
audioSource.clip = heartSound;
audioSource.Play();
Destroy(gameObject); //Destroy heart
}
--------script on camera
static function fnLowerMusic()
{
Debug.Log("fnLowerMusic() called");
//Lower zone music volume
GameObject.Find("Player").GetComponent("AudioSource").volume = 0.0;
//Resume zone music volume
yield WaitForSeconds (5);
Debug.Log("Waited 5 seconds");
GameObject.Find("Player").GetComponent("AudioSource").volume = 1;
}