Skip to main content
Search our knowledge base

How do I play multiple Audio Sources from one GameObject?



  • Dumitrache Catalin

    Cool , thank you !

  • Deeds

    How and why does this work?


    What are the costs of doing this?


    And why do you cache a reference (seemingly unnecessarily) to the AudioSource?

  • Shanice Alexis

    @Deeds To answer your last question: you use GetComponents<AudioSource> to retrieve all AudioSource instances, from which you can then extract the relevant audio clips. Not sure why this isn't shown in the code example though. You might find this more helpful:

  • Deeds

    Sorry, I still don't see how the reference is being used. 


    Nor how this works. 


    Is the code example completely wrong? It seems like it is.



  • Shanice Alexis

    It's outdated. You'd maybe do something like this:


  • Deeds

    argh. THANK YOU!


    This is almost exactly what I'm doing... and I kind of felt like it was overkill to have an AudioSource for every single AudioClip, so went hunting for ways to play multiple clips at the same time, through one AudioSource.

    Which lead me to here, and confusion.

    Seems there really is just a one:one ratio between AudioSources and AudioClips.


    Again. Thank you. Your way seems better than mine... an ARRAY! I'll try it.


  • mrochefort12v

    The code example is either wrong or outdated because according to the Scripting API, .PlayOneShot() is called on an AudioSource not an AudioClip. 


  • Brona Martin


    I want one empty game object to trigger 8 separate audio sources which are in a circle around the player. How do I do this? I am not very good at programming. I want the player to walk into the middle of room and then trigger the sounds. And then when they leave the sound stops.

    Many thanks!


Article is closed for comments.