- Home /
Two AudioSource Components on one Gameobject?
Is there a way to access two audio source components from one script and have them play at the same time?
The two audio components are on one object. Thanks
what are you trying to do?
listen to environment send to radio and listen from radio?
could be good idea, ... but I have no knowledge about that
was wondering if the audio sources could be access using something like
var my$$anonymous$$usic: AudioClip;
var my$$anonymous$$usic2: AudioClip;
function Start()(
AudioSource1.audio.clip = my$$anonymous$$usic;
AudioSource2.audio.clip = my$$anonymous$$usic2;
audio.Play(AudioSource1);
audio.Play(AudioSource2);
}
I know this is SOOOO WRONG when it comes down to the actual logic of it but hypothetically could you use 2 audio sources or would you have to create multiple gameobjects with separate audio sources and use a sound manager to control the music?
Answer by mhdmnaina · Apr 24, 2015 at 02:28 PM
Public Audiosource audio1,audio2; audioclip ac1,ac2;
void start() { ac1 = Resources.Load("(audioname)"); audio1.PlayOneShot (ac1); // playoneshot will play one time
ac2 = Resources.Load("(audioname)"); audio2.Play (ac2); // play will play loop times }
void Update() { }
Your answer
Follow this Question
Related Questions
Play sound from an array, not random, and only once 3 Answers
Intensity of sound. -1 Answers
Using Distance from AudioSource 0 Answers
Random, 3d sound. 1 Answer
Set audio clip to 3D in script 1 Answer