Hi Guys,
I’m trying to find the pros and cons of using PlayClipAtPoint, giving each object their own AudioSource, and making an AudioSource pool. Here’s what I see.
A SoundManager managing an AudioSource Pool
Pros
- Will handle when clips can/cannot override each other.
- Can be called from any class as a Singleton.
- One simple set up will manage sounds in every scene.
- Can manage how many clips are being played simultaneously (for optimization).
Cons
- All AudioSources will have the same set up (Unless you create a load of presets to choose from, when making a sound. That could be a lot of work).
- You can’t play a sound from a location (you can, but PlaySoundAtPoint defeats the object of having a pool of AudioSources). - NOTE: You could have them as children object’s, which move to the location they need to be played, I suppose… but that’s a little more fiddly, and you still miss out on the unique set up of each.
Each GameObject with AudioSource
Pros
- Can give each AudioSource their unique set up (rolloffMode, spacialBlend, all that good stuff).
- Especially good with prefabs.
- Keeps nice, clean, component type architecture.
- No knowledge of the outside world required to use clips.
Cons
- Each has to be manually set up and tweaked.
- May result in lots and lots of AudioSource’s in the scene, if there’s a lot happening.
- Cannot manage the number of sounds being played at once.
- May be difficult to make bulk changes, as Unity cannot manage any nested prefabs.
One AudioSource allowing other classes to call PlayClipAtPoint()
Pros
- Very simple to set up
- Only one AudioSource required in the scene
- Can be used as a singleton very easily
Cons
- Cannot easily customize for each individual sound.
- Whenever called this creates a new AudioSource at the location, which may be garbage collected, possibly actually being a slower process being the scenes (Can anyone clarify this).
- AudioSources will not follow the object that made the sound (if it’s a moving object).
When you are making sound effects for your game (all enemies, players, environments, ect). How do you do your sounds?