I initially posted this on an old topic ( here ), but I wanted to avoid necroposting if it was preferable to have a fresh topic nearly 2 years later.
The linked thread discusses the exact problem I was having today; I have multiple StudioEventEmitter
components each on their own child object of my entities. I would like to be able to easily swap out the current event reference associated with that emitter during runtime in order to keep things tidy while affording me the control I want over the audio. This is not possible by simply changing the EventReference
associated with my StudioEventEmitter actionAudioSource
, i.e.:
public void Footstep()
{
if (actionAudioSource != null)
{
actionAudioSource.EventReference = actionFootstepEvent;
actionAudioSource.Play();
}
}
The above thread contains a solution on how to implement a method to manually look up and change the reference, so that’s great! But where I continue to be a little confused (and slightly nervous) about when it comes to integrating FMOD Studio into my project are best practices. I realize that every project has different needs, but that’s not much of a barometer for me with what little understanding I currently hold over the nuances of implementing this audio solution.
For me, a new FMOD Studio user reading up on how to call audio events in Unity, what caused me to eventually decide on a solution of limited emitters for a given entity for each audio context (one for actions, one for voices, one for getting hit, etc) was that I could not wrap my head around the advantages of PlayOneShot
(Not held in memory, but more limited out of the box re: controlling parameters), versus creating instances (held in memory but not automatically released, must do own GC).
I very well may be mistaken; this is my current understanding based on poring over documentation, as well as other developers’ YouTube videos, blogs, and forum posts here. I was very surprised that it took me long to find this particular method of having a dedicated emitter from which you can load the appropriate events. (Which Just Works with Unity’s default AudioSource
/ AudioClip
interaction)
public StudioEventEmitter voiceAudioSource; //Used for any voice callouts this entity may have.
public StudioEventEmitter actionAudioSource; //Used for emitting effect sounds related to attacks and such.
public StudioEventEmitter hitAudioSource; //Dedicated sound emitter for hit and damage effects.
public EventReference voiceAttackEvent;
public EventReference actionAttackEvent;
...
For me as a game designer, this seems like a logical, if not simplistic (though I am making a retro styled game with relatively simplistic audio anyway) solution.
cameron-fmod, who graciously provided a workaround in the linked thread, then said:
After a lot of internal discussion, we came to the conclusion that this was not the ideal way to use the StudioEventEmitters.
I can accept this, but for the sake of education, could you go into a bit more detail as to why this approach may not be ideal? I want to be sure I’m not setting my project up for a situation where I shoot myself in the foot.
Love FMOD Studio and there’s no way I can go back, but on this most basic point, I’m not as confident as I’d like to be. Thanks in advance!