1
\$\begingroup\$

Building an RTS I have several hundred units on screen at one time.

Whenever a Unit attacks/gathers something, I want to play a sound (if camera is close enough).

My question is, how do most RTS games do this? Do I play 1 sound per attack per unit, i.e if 200 units are fighting do I play 200 individuals sounds (one sound each time a unit attacks)?

Same goes for gathering, if 20 workers gather wood, do I play a sound each time they hit a tree?

Does this not use up a lot of resources? Is there a better way?

\$\endgroup\$
  • \$\begingroup\$ I don't know, but I assume it depends on the case, and on your choice: if you have 100 soldiers and all of them are shooting an enemy, I guess you'd want them all to play shooting sounds and not play one shooting sound, to create a battlefield effect. \$\endgroup\$ – lihail Mar 29 '20 at 12:39
2
\$\begingroup\$

Yes, every event causes an audio source to play. But if you just naively play sound effects in an additive manner, then it is hard to get the volume right so that one unit can be heard but 100 units don't cause an eardrum-rupturing cacophony of noise.

Fortunately the Unity audio mixer system can help you with that. If you add a normalization filter to your audio mixer chain, Unity will adjust the volume of individual sound effects in a way that the volume of the final mix is always within a reasonable range.

And then there is of course the question of where you place your audio listener. You could place it on the camera as usual, but then almost all the battle noise will come straight from the front. Personally I find it quite pleasing to cheat a bit and place the audio listener closer to the ground. This gives you more stereo sound which results in a IMO more satisfying "being on the battlefield" ambience vibe.

I am looking forward to hearing your game.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.