Sphere
Log in Join
☆ 8

unity audio sources cutting out when many enemies shoot at once

Unity 2022.3.20f1, 2D shooter. Every enemy plays a short laser sound via AudioSource.PlayOneShot on a shared AudioSource attached to the player. When 20+ enemies fire at once the sound gets thin and some shots are silent. Console doesn't show errors. I know there's a limit on simultaneous voices but I can't find where to raise it, and PlayOneShot from a single source means only one plays at a time anyway, right? Should I pool AudioSource components instead? What's the sane architecture for lots of one-shot SFX?

⚑ Report

4 replies

☆ 0
G ghost ·2026-11-05#1

PlayOneShot on one AudioSource can stack multiple clips - it's designed for that, up to the voice limit (32 real voices in Unity, 64/128 virtual depending on settings). When you exceed it Unity steals the quietest/oldest voice, which is why it sounds thin. Check Edit > Project Settings > Audio for voice counts. Pooling sources doesn't raise the global limit.

⚑ Report
☆ 0
C cardboard ·2026-11-05#2

Audio settings show 32 real voices. That's probably it. But pooling still feels necessary so I can apply per-enemy volume/pan. If I pool 10 AudioSources and round-robin them, is that better or just moving the problem? Also is there a way to prioritize enemy sounds over ambient music?

⚑ Report
☆ 0
C cod ·2026-11-05#3

Pooling ~8-12 sources with round-robin is the common pattern and lets you set spatial blend/pan per source. Set music to a lower priority in its AudioSource (lower number = higher priority, so SFX -100, music +100) so SFX steal voices from music, not each other. Also don't play a sound for every projectile - a 20-enemy volley sounding like 4 shots is perceptually fine.

⚑ Report
☆ 0
W works ·2026-11-07#4

Went with a pool of 10 sources, priority -100 for SFX, music at +100, and a cooldown so a given enemy can't fire its sound more than once per 0.08s. Silent shots basically gone and the mix is cleaner. Turned out half the problem was 20 identical laser clips stacking into a wall of noise that I mistook for voices dropping. Limiting duplicates fixed the sound more than raising any limit.

⚑ Report
Log in to reply.