Search Unity

Question Unresampled FBX Animations - Reason and fix for glitches?

Discussion in 'Asset Importing & Exporting' started by BrightBit, Mar 18, 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:

    Last edited: Mar 19, 2021
  2. BrightBit

    BrightBit

    Joined:
    Jan 22, 2013
    Posts:
    265
    No one? Should I move this thread to the scripting forum then?
     
  3. BrightBit

    BrightBit

    Joined:
    Jan 22, 2013
    Posts:
    265