Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Blender animation IK vs FK

Discussion in 'Asset Importing & Exporting' started by MP84, Feb 14, 2016.

  1. MP84

    MP84

    Joined:
    Mar 7, 2015
    Posts:
    7
    Hello,

    I have a simple animation in Blender - two deformable bones and one IK bone. I have keyframes only for the IK bone. Now, when I load such blend file in Unity, it ignores the IK bone (non-deformable one) and correctly calculates animation for other bones, even those don't have any keyframes in Blender. I like this behavior, but I have few questions:

    1) can I rely on this behavior (unity not loading IK (non-deformable) bones and calculates animation for other bones)? Because after I checked some forums, before I started playing with animation, I thought I would need to export my animation as FBX file with "only deform bones" check in blender. So it seems like I do not need to do that after all.

    2) should I be using this approach - animating IK bones and then letting Unity calculate animation for the other bones on import, or is it better (safer/more efficient) to use IK bones in Blender and then bake the animation to normal bones?

    Thanks,
    Michal P.
     
  2. _GimbalLock_

    _GimbalLock_

    Joined:
    Feb 26, 2013
    Posts:
    137
    Hi Michal,

    I'm more familiar with the process in Maya but I do a lot of modeling in Blender, but....

    When it comes to skeletal animation you import the skeleton with the animation baked down to the bones you want to use in Unity. Constraints like the IK solver are specific to Blender or whichever program you created the content in.

    I tend to think of the control rig and the skeleton used for deformations as two separate systems. Since the IK is part of the system Unity won't use, the animation would need baked to the bones you will be using in Unity.

    Unity supports IK on the Mecanim. But that is separate from using IK on a control rig in Maya or Blender.
     
    Last edited: Feb 14, 2016
  3. Cygon4

    Cygon4

    Joined:
    Sep 17, 2012
    Posts:
    382
    Yes you can rely on this behaviour.

    Explanation: Currently, Blender -> Unity conversion always means using FBX (even if you don't, Unity calls Blender.exe to export your .blend file to .fbx, then imports that)

    Blender's FBX exporter goes over all your Actions (= animation clips in Unity) and creates keyframes for all bones at every full frame (in Blender terms, this is called "Baked Animation").

    It then removes non-deforming bones (unless they're parents of a deforming bone) and what's left ends up in the FBX file. You can use IK, spline IK, physics and whatever you want in Blender, even on non-deformation bones, if a deformation bone is moved by it, it will be in the exported FBX.

    If you want more control over the process, you can do the FBX export yourself, the exporter settings let you control the sampling rate and smoothing (bottom 5 options):

    blender-fbx-export-settings.png

    It has been like that as far as I remember (Blender 2.5x at least) and Blender 2.76 will remain the version of choice for a while yet as the Blender team has called a feature freeze to prepare the next big version (2.8 or possibly 3.0).
     
    Last edited: Feb 15, 2016
  4. MP84

    MP84

    Joined:
    Mar 7, 2015
    Posts:
    7
    Thank you.

    Seems like it does not matter which approach you choose in most cases, but you should stay with it and do not mix it. I mean, I have basic model with armature (skeleton) in one blender file. Gear parts with the same armature in different blender files and animation(s) in another blender files. Everything works, I can add gear to the model and play animations. But If I export, for example one animation as FBX file, it stops working because bone structure (bone names) in the FBX file is not the same as armature in blender file.
     
  5. Cygon4

    Cygon4

    Joined:
    Sep 17, 2012
    Posts:
    382
    I'm using a very similar setup:
    • one .blend file contains the character + his/her gear
    • other .blend files link to the character's .blend file and contain the animations
    I don't understand why in your case the bone names should change (it's the same armature, linked/appended from the blender file with the basic model, right?).

    For me, it works as long as I reference the original file's Unity animation "Avatar" in the animation files:

    unity-import-linked-blendfile.png
    If it helps, I attached a .zip file containing such a setup (model in one .blend file, animations in another) that should get imported correctly by Unity (at least I hope the Avatar assignment is recorded in the .meta file).

    Oh, and a list of other things I found out over time by trial and error:
    • Always have an animation in the .blend containing the character and gear, even if it's a dummy one
    • If you export to FBX manually, turn on "Baked Animation" even for the .blend file with the character and gear
    • Always import this animation in Unity, even if you don't use it
    • Always have a mesh with painted weights in the .blend containing the animations
    • If you export to FBX manually, always include at least one mesh with painted weights when exporting the .blend file containing the animations (to trim down .fbx size, I went as far as to have a weight-painted single triangle that I export with the animations :p)
     

    Attached Files: