PlayOneShotAttached gives a "has not had EventInstance.set3DAttributes() called on it yet!" warning and doesn't play the sound


(Glowfish Interactive) #1

Hi,

I’ve been having issues with playing a sound using FMODUnity.RuntimeManager.PlayOneShotAttached.
Using this method I often get the following warning, in combination with the sound not playing:

"FMOD Studio: Instance of Event event:/SFX/Destructables/wood_destruction has not had EventInstance.set3DAttributes() called on it yet!
UnityEngine.Debug:LogWarningFormat(String, Object[])
FMODUnity.RuntimeManager:Update() (at Assets/Plugins/FMOD/RuntimeManager.cs:350)
"
Any idea what might be the cause of this? I have not yet been able to determine the exact cause as this doesn’t seem to be the case in all situations where I use the method.

Additionally I tried changing the function a little bit:
public static void PlayOneShotAttached(Guid guid, GameObject gameObject)
{
var instance = CreateInstance(guid);
AttachInstanceToGameObject(instance, gameObject.transform, gameObject.GetComponent());
instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform)); //What I added
instance.start();
instance.release();
}

And that seems to fix the problem but I’m not sure of this is the correct way to work around this or if this would cause any other issues.

Some feedback and help would be greatly appreciated!


(Cameron Baron) #2

Are you sure it is coming from the event created by PlayOneShotAttached?
Could it be coming from somewhere else you are using that event?
I am able to use PlayOneShotAttached without getting that warning.


(Glowfish Interactive) #3

I am 100% sure as replacing the call with a regular PlayOneShot doesn’t cause the error. And the event that I was using was only being used in 1 location in the project.
I can also use PlayOneShotAttached in most situations but in this case, things break.
I do have to mention though that I’m guessing the problem is being caused by playing an attached one-shot while the object in question gets destroyed later in that same frame due to a chain of events (for example a damage event started the event but also caused the hp to drop far enough to kill the object). (Not confirmed)


(Cameron Baron) #4

It does appear that the object could be destroyed before set3DAttributes is actually being called, which doesn’t actually happen until the next Update.

By adding your change:
instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform));
To the PlayOneShotAttached function, we can make sure the position is set at the time the event is created, which should solve this problem.

I will get this added for the next public release.