menu
 

La section Questions et réponses de la communauté Audiokinetic est un forum où les utilisateurs de Wwise et de Strata peuvent poser des questions et répondre à celles des autres membres de la communauté. Si vous souhaitez obtenir une réponse de la part de l'équipe de soutien technique d'Audiokinetic, veillez à utiliser le formulaire de Tickets de Soutien.

+2 votes

[Relating to WWISE in Unity]

Let's say you want to trigger a sound effect when a Unity gameobject is destroyed (e.g. item explodes or is collected).

As I understand it when you call AkSoundEngine.PostEvent, "At runtime, an AkGameObj component is automatically added to this GameObject", but if I Destroy the Unity GameObject after posting the event, I get the error:

Wwise: Unknown game object ID. Make sure the game object is registered before using it and do not use it once it was unregistered.(Object: [myobjectname] (UnityEngine.GameObject))

 

Seems like a very common scenario - is there a recommended way to handle this case?

 

dans General Discussion par Chris (690 points)
I've tried a couple workarounds for this too,  these also seemed to give a console warning:

--- #1 - Create a new object just to play the sound whilst deleting the originating object ---
I created a new component for these OneShot sounds: I then play a sound via that component (and delete the originating game object) - I did this via a PostEvent with a callback that was called when the Event ended. In that callback, I delete the OneShot object.

--- #2 - Unregister before deleting the object ---
I post the event and then immediately unregister the game object with the sound engine.
Quick update: I hear that this is resolved in the very soon to be released WWISE 2014.1.6 and 2015.1

1 Réponse

0 votes
 
Meilleure réponse
For me, this appears to be fixed in the recently released WWISE 2015.1 - seem to be able to Destroy() objects without generating any warnings
par Chris (690 points)
...