- Home /
Multiple Audio Source Problem
Hi,
I'm trying to add all the gun sounds I need for my FPS game into the gun game object. I'm currently trying to use this to add the firing sound (audio1) and reload sound (audio2) but it doesn't seem to let me add them in the inspector.
var audio1 : AudioSource;
var audio2 : AudioSource;
Then I use this to call them when it's firing/reloading...
audio1.Play();
audio2.Play();
So, how would I go about using this method of multiple audio sources on one gameObject, to add them in the inspector? When I drag the two audio's from the project into the inspector slots for audio1 and audio2, they don't let me put them there. I also tried this with a regular AudioSource but it didn't let me add more than one.
How can I fix this? Or, is there another (easier) way around this?
Thank you.
Sounds like you only need one AudioSource, but two AudioClips?
Yes, but it does not let me add them to the inspector, not sure why. Here's how it looks:
When I drag the audios to those variables, they don't go there. Why is this?
Answer by tanoshimi · Dec 07, 2013 at 11:54 PM
I think you may be confused between AudioSources and AudioClips. Here's a great introduction you might find helpful: http://www.gameaudio101.com/Unity-Audio-Tips.php
Thanks, this did clear up the confusion between audio clips and audio sources, but I'm still unsure of how to solve my problem.
Never $$anonymous$$d, fixed! It let me add two audio sources. I'll accept the answer, though, because it did help quite a bit.
Your answer
Follow this Question
Related Questions
Can I play multiple AudioSources from one gameobject? 8 Answers
Multiple Sound Effects? 1 Answer
Multiple audio samples on one object. 1 Answer