Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio how many audiosorces do you use?

Discussion in 'Audio & Video' started by alex1st1, Apr 20, 2019.

  1. alex1st1

    alex1st1

    Joined:
    Jan 26, 2019
    Posts:
    275
    hi all!
    watching tutorial https://unity3d.com/ru/learn/tutorials/projects/2d-roguelike-tutorial/audio-and-sound-manager I found it stange to have 1 (one) audiosource for all sound effects in game.

    is it possible to:
    1. add audiosource to every gameobject that has sfx - e.g. each enemy instance will have its own audiosource or many of them - for each different sound enemy has.
    2. run its .play method every time you need?

    If no - why? memory issues? performance? mixing?

    2nd question: I see there are significant changes from ver 4 to 5, what is best tutorial for ver 2018?+
     
  2. Docaroo

    Docaroo

    Joined:
    Nov 7, 2017
    Posts:
    82
    You can have loads of AudioSources ... the number is specified in the Project Settings for Audio.

    upload_2019-5-15_12-35-3.png

    This means that 32 audio sources can actively play sounds at once ... and this can be increased.

    What we tend to do though is have a pool of AudioSources that can be called up and assigned various audio clips to play back combat sounds through ... that means we don't end up creating hundreds of audiosources and then needing to handle and destroy them - we simply cycle through the available audiosources in the pool.