Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes

Hey everyone,

I'm using Wwise 2024.1.6.8842.3614 with Unity 6000.0.47f1.
I'm having an issue that I've seen discussed but never properly solved before: the soundengine itself works perfectly and I can play music, sound effects, etc. . But as soon as I add a "AkGameObj" component to any GameObject for spatial audio, I get spammed with the error message "Wwise: Unknown/Dead game object ID used in function SetPosition. Make sure the game object is registered before using it and do not use it once it was unregistered.". 

I've been pulling my hair out over this debugging the readable C# part of Wwise, trying to register the GameObject manually before it gets enabled, trying different script execution orders, trying to find wwise events that fire once the sound engine is initialized, etc. and I've found one slightly convoluted solution that makes me scratch my head which is why I wanted to share it while also asking why it's not documented anywhere and whether I'm getting something wrong:

If I don't add an AkGameObj component to the respecitive GameObject but instead attach a script that adds the component after one frame, everything seems to work fine and I don't get any errors with spatial audio properly doing its thing. Here's the code that works:

    private void Awake()
    {
        StartCoroutine(AddAkGameObjDelayed());
    }

    private IEnumerator AddAkGameObjDelayed()
    {
        yield return new WaitForEndOfFrame();
        gameObject.AddComponent<AkGameObj>();
    }

Why does this happen and why is adding the AkGameObj component like this necessary? The soundengine claims to be initialized but the fact that this works while just adding the AkGameObj directly in the editor spams me with errors, tells me that the Wwise initialization process does something under the hood that takes longer than one frame.

Thank you for your help

ago in General Discussion by Alexander Loosen (100 points)

Please sign-in or register to answer this question.

...