Unresampled FBX Animations - Reason and fix for glitches?

I rewrote Blender’s export_fbx_bin.py and Unity’s Unity-BlenderToFBX.py script to not bake additional keyframes between the main keyframes that I placed manually for an animation in Blender. I also had to write a custom AssetPostprocessor to disable Unity’s curve resampling:

void OnPreprocessModel()
{
    ModelImporter modelImporter = assetImporter as ModelImporter;
    modelImporter.resampleCurves = false;
    modelImporter.SaveAndReimport();
}

However, this is how the animation looks now:

6950183--817574--Glitch.gif

I am using the legacy animation system and at first I thought that Unity’s curve resampling is doing more than just adding additional keyframes but the generic animation system with Unity’s curve resampling disabled via the inspector does not have this problem.

Do you have any ideas on what’s going on here?

By the way despite looking weird in the game view the animation looks perfect in the preview in the inspector:

6968729--821387--preview.gif

Some details:

Unity 2020.2.6f1 Personal
Blender 2.90

You can find the modified versions of the aforementioned scripts in the attached zip file. I also provided a Unity package that contains the blend file with the animation shown above if you want to give it a try.

The file locations for the script files are:

\Hub\Editor\2020.2.6f1\Editor\Data\Tools\Unity-BlenderToFBX.py
\Blender 2.90\2.90\scripts\addons\io_scene_fbx\export_fbx_bin.py

6968729–821390–PythonFBXScripts.zip (36 KB)
6950183–817772–UnresampledAnimation.unitypackage (298 KB)

Did you already make a prefab out of it before when it was imported? If so, that prefab might not be valid anymore (because stuff moved or changed names subtly) and you just need to remake it from the freshly-imported stuff.

If it isn’t that, then I’m going to guess it is related to the (-90,0,0) rotation applied automatically when you import from Blender and some part of that got disrupted. I base that statement on the weird 90-degrees off of the arm-on-hip.

Looks like a cool enemy for something like Dead Space though…

No. I didn’t make a prefab out of it at all.

At first I thought so, too. However, it doesn’t make sense for a couple of reasons. For example: Not every bone is affected equally by that problem and the inspector preview is showing the animation correctly.

So it’s terrifying in more than just one way. :smile: