Question by
Brandon236 · Mar 01, 2017 at 07:25 AM ·
audioaudiosourceaudioplay
Having multiple audio sources in a single object?
If I have multiple audio sources in an object then how do I set which sound effect I want to play at a specific time? Here's the script I'm using:
public AudioSource[] sound;
public AudioSource sound1;
public AudioSource sound2;
void Start () {
sound = GetComponents<AudioSource>();
sound1 = sound [0];
sound2 = sound [1];
}
And to play the sound I use
sound1.Play ();
The strange part is that no matter how I set the array values, it keeps playing the sound2 audioclip instead of the sound1 one. Even stranger is that if I disable the sound2 audioclip, it doesn't play anything. So what's going on?
Comment
Your answer
Follow this Question
Related Questions
Trying to use audio causes errors when trying to use in an 'if' statement 1 Answer
Delaying Audio with PlayedDelayed not working 1 Answer
Audio coming through iPhone earpiece 0 Answers
Can not play a disabled audio source, but the source is definitely not disabled! 0 Answers
Play sound when move by using script 0 Answers