Syncing exported FaceFX FBX animaiton with the audio file in Unity

Hi All -

Doug's been helpful in pointing me in the right direction on this, but he mentioned it would be a good post for the forum.

What's the best way to sync the FBX animation from FaceFX with an audio file in Unity? Do you simply just start the animation and the audio file at the same time (assuming the start of the FBX file matches the start of the audio file)? Is there a better way?

Thanks,

Matt

Thanks for posting this Matt. It's a good question and one I'm sure other people will have.

In the most simple case, yes. You export an FBX file from FaceFX, load it into Unity, then start the animation and the audio at the same. If your animations are short, this it probably good enough, but for longer animations, you may want to force-sync the animation and the audio.

Force-syncing
Before playing the animation in Unity, set the AnimationState speed variable to 0, so the animation does not play on it's own. Then play the animation and audio and in your Update() function, set the AnimationState time variable equal to the AudioSource time variable.

Negative Keyframes
Regardless if you force-sync or not, you want to make sure that the start of your audio matches the start of the animation. To do this, make sure that the visible FaceFX timeline starts at frame 0 when you export your FBX file. FaceFX can create negative keyframes if your audio starts right away (try to make sure there is a few hundred milliseconds of audio before talking starts), and you don't want the FBX file to start with the negative keyframes, or the audio will be out of sync from the start.

Permalink

Hi Doug -

That actually works pretty good. The thing that made the most difference was setting the Start value of the animation to 0, since FaceFX has the negative keyframes. I didn't need to use the AnimationState class to force-sync. I simply played the audio clip and animation from within the Update method.

Thanks for the help.

Matt