Question by
LordBoogr · Mar 11, 2016 at 01:39 AM ·
audioaudioclipaudio sourceaudioplayaudio.play
I'm trying to do multiple AudioSources, but one won't play......
import UnityEngine.SceneManagement;
#pragma strict
var maxFallDistance = -50; var audio1: AudioSource; var audio2: AudioSource;
function Start () { var aSources = GetComponents(AudioSource); audio1 = aSources[0]; audio2 = aSources[1];
if (transform.position.y > maxFallDistance) { audio1.Play(); }
}
function Update () {
if (transform.position.y <= maxFallDistance)
{
audio1.Stop();
}
if (transform.position.y <= maxFallDistance)
{ audio2.Play(); } }
I wanted one song to play normally, while the other one only plays when my player falls. But when I run it and my player falls, it's just silence. I know the problem isn't the AudioSource. But how do I get audio2 to play?
Comment