Search Unity

Question Unresampled FBX Animations - Reason and fix for glitches?

Discussion in 'Scripting' started by BrightBit, Mar 24, 2021.

  1. BrightBit

    BrightBit

    Joined:
    Jan 22, 2013
    Posts:
    265
    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:

    Code (CSharp):
    1. void OnPreprocessModel()
    2. {
    3.     ModelImporter modelImporter = assetImporter as ModelImporter;
    4.     modelImporter.resampleCurves = false;
    5.     modelImporter.SaveAndReimport();
    6. }
    However, this is how the animation looks now:

    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:

    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:

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

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    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...
     
  3. BrightBit

    BrightBit

    Joined:
    Jan 22, 2013
    Posts:
    265
    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. :D