Best location for sound fx component

Suppose I have 50 coins on level (all instances of one game object).
What is best for performance?

  1. Attach sound component to this “coin” game object (then all 50 instances will have this component) or
  2. Attach sound component to some “sound player” game object, which have only one instance.

Also, is there any perfomance difference when we send messages from one component (script) to another (sound, sprite) or when we send messages to component attached to different game object (maybe even with different socket:)?

Hi
I my experience I have had better workflow putting all sound objects in a sound gameobject and calling it either via messages to a sound script on that same gameobject or via a lua module.
Why having this script/lua module in between is because you can then handle groups (sfx, music), blending, gating etc.

The only time I can see putting sound in the actual “gameinstance” object (eg a coin) as a better option is if you want to fiddle with sound positioning, mixing several sounds as dry och wet depending how close it is to the camera etc (which I am doing in my last project). This is of course my own approach and in no way the official way to do it.

3 Likes

I agree. Having the sounds in a single place and played through a single script gives you better control of playback, blending, gating and so on.