Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Audio Singleton Audio Manager for 2D game

Discussion in 'Audio & Video' started by Timo_Henderson, Feb 8, 2020.

  1. Timo_Henderson

    Timo_Henderson

    Joined:
    Oct 16, 2019
    Posts:
    3
    Hi, I've been looking around for the best way to implement audio in a 2D game. The most common way I've found (on Brackey's, Unity Learn etc.) is to make a singleton audio manager and play everything through this. However it doesn't seem like using this method will give the sounds any kind of spatialization or panning and everything will just sound like it's coming from the centre. Am i right about this or am i missing something? Or is this a non issue that I'm struggling to come to terms with? Any help, advice, or opinions would be much appreciated.
     
  2. Solbirth

    Solbirth

    Joined:
    Dec 13, 2019
    Posts:
    4
    Timo_Henderson likes this.
  3. Timo_Henderson

    Timo_Henderson

    Joined:
    Oct 16, 2019
    Posts:
    3
  4. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,303
    Don't have a pool of audiosources.
    Have a pool of gameobjects that each have their own audiosource component.

    If you need the audio to play from a specific location, just move the gameobject to that location.
    If you need the audio to move while it's playing, then move the gameobject.
    If you need the audio to follow another game object, just set it's parent to the other gameobject, and attach and detach as needed.
     
    Timo_Henderson likes this.
  5. Timo_Henderson

    Timo_Henderson

    Joined:
    Oct 16, 2019
    Posts:
    3
    That's a nifty solution. Thanks