- Home /
Any idea for storing multiple audio sources?
Hiya, I googled my problem, but didn't find anything, so no idea if there's any simple workaround for it.
Let's say that I have character that can play like 20+ sounds, so my first idea was to add 20 audio sources to the character, but anyone who dealed with Audio Sources know that they are a real pain when you have to go through them all, when they have same names and takes lots of space in inspector after expanding. I need sounds to follow the character, to be in 3D, and to be able to alter their pitch and volume as well, so I need to configure them in the Audio Source first.
If anyone has any ideas or already overcame this problem, then let me know, I will be really grateful.
Use one AudioSource. You can use AudioSource.clip to assign any AudioClip at runtime and AudioSource.Play to play it afterwards. If some clips should have a different pitch etc., I would create a simple class that holds the information and use this in an array or list so you can prepare those values and use them as needed during runtime.
Your answer
![](https://koobas.hobune.stream/wayback/20220612125138im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Use audio to change the emission of an object. 0 Answers
How can I play multiple audioclips from the same object? 2 Answers
How to AudioSource.GetSpectrumData while muted? 1 Answer
Mix/Transition audio at any given moment? 2 Answers
Does the number of simultaneous playing audio sources matter? 0 Answers