Animations Script to Post Events

Hi !
We are experimeting our 1st project with FMOD we have used Wwise for 10 years.

I am missing a SCRIPT to post EVENT like we were With Wwise, let me share the script.

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using UnityEngine;

public class AKPostAnimationEventTarget : MonoBehaviour
{
    public GameObject Target;
    public void PostEvent(string pEventName)
    {
        if (Target == null)
        {
            Target = gameObject;
        }
        // print("Post Anim Event: " + pEventName);
        AkSoundEngine.PostEvent(pEventName, Target)
    }
}

So basicly our Wwise script was able to integrate on any gameobject using animator , then we were able to post Sound related to the STRING name in the FBX or a new Key in the Animation by using PostEvent fonction , so we could triggers 30 000 audio fille different based on the string name.

We do not want to have different script for eachs sounds or having to script for each sound in the animation , we want to use 1 script that will rule all the animation , like it was in Wwise. We have over 20k audio files integrated into animations for each project.

I tried to convert the script for FMOD

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using UnityEngine;

public class FMOD_AnimationEvents : MonoBehaviour
{
    public GameObject Target;
    public void PostEvent(string pEventName)
    {
        if (Target == null)
        {
            Target = gameObject;
        }

        FMODUnity.RuntimeManager.PlayOneShotAttached("pEventName", Target);
    }
}

Altough when I hit the animation key i have a warning
[FMOD] Event not found: pEventName

So it dosent trigger the string event name i have integrated in the postevent fonction.

How can I code 1 script that will post the string from the .FBX

The problem is the quotes around ‘pEventName’, it should be:

FMODUnity.RuntimeManager.PlayOneShotAttached(pEventName, Target);
1 Like

Bingo Flawless ! So beautiful script , thanks a lot for the fix Cameron really appreciate !

Yann

1 Like