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

How to use Animation Rigging BakeUtils?

Discussion in 'Animation' started by danielNTM, Nov 6, 2020.

  1. danielNTM

    danielNTM

    Joined:
    Mar 1, 2019
    Posts:
    4
    I'm trying to create a workflow where I create some animations in editor using IK constraints (mainly just the Two Bone IK constraint for each of the limbs). This seems to be an easier way to create animations rather than brute forcing each bones' transform/rotation. I don't intend on changing the constraints at runtime, so I was wondering if I can bake the animation imposed by the constraints directly into the skeleton. It looked like BakeUtils.TransferMotionToSkeleton would get the job done, so I created a simple script with an inspector button extension to bake it via the editor once I'm done. Unfortunately it doesn't seem like it's doing anything. It does end up creating new keyframes for the affected bones, but the values are not set to what the constraints would have produced. No errors in console.

    The goal is to use the IK constraints to easily create my humanoid animations, then bake the result into a vanilla animation without rig constraints. Any advice as to what I'm doing wrong here? Is there some other standard workflow/util I'm supposed to be using instead of my makeshift approach (I want a workflow like the 2D? I'm trying to get by without buying solutions like Final IK.

    Very new to Unity and still learning. Any help would be appreciated!
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi,

    I think what you want to use is this:
    https://docs.unity3d.com/Packages/c...g@1.0/manual/BidirectionalMotionTransfer.html

    The function `BakeUtils.TransferMotionToSkeleton` you are referring to is used in Bidirectional motion transfer to bake character animation with constraints back to FK. I believe this should cover what you intended to do.

    Also, you can have a look at this presentation we've made at GDC about it this year:
     
    danielNTM likes this.
  3. danielNTM

    danielNTM

    Joined:
    Mar 1, 2019
    Posts:
    4
    Excellent presentation, thanks!

    As far as the bake util goes, for me the option to transfer motion is disabled. I'm now realizing this might be because keyframing humanoid rig is not allowed? I'm taking animations from mixamo, importing them into Unity and trying to make fine adjustments. Is this possible directly in Unity editor or am I going to have to use another authoring tool like Blender?
     
  4. potovaregina

    potovaregina

    Joined:
    Nov 7, 2020
    Posts:
    1
  5. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Yes, we had to disable Bidirectional baking for humanoid. Unfortunately, humanoid was never built to author clips, and while default values for humanoid make sense in a runtime setup (the relaxed pose defines a sane character setup to be used for arms and legs IK), it doesn't really make for a user friendly authoring setup.

    However, if your end goal is producing generic clips for your character, you can easily work around that limitation.

    Have a look at the GameObjectRecorder:
    https://docs.unity3d.com/ScriptReference/Animations.GameObjectRecorder.html

    It's the core technology used by Animation Rigging in bidirectional baking to generate animation clips out of animation data. If you pre-process your humanoid clips in the GameObjectRecorder, you can create generic clips that you can then touch up using Animation Rigging.

    If your end goal is producing humanoid clips. This is a bit more complicated. The only way you can write humanoid data is through the model importer. Thus, the best way to convert your generic clips back to humanoid would be to re-export them to FBX so they can be processed back by the model importer. You can use the preview package FBXExporter to do that.
     
  6. danielNTM

    danielNTM

    Joined:
    Mar 1, 2019
    Posts:
    4
    Got it. Thanks for the tips and quick turnaround!
     
  7. itsnarutofan

    itsnarutofan

    Joined:
    Sep 6, 2020
    Posts:
    6
    Is there a way to enable it please reply?
     
  8. itsnarutofan

    itsnarutofan

    Joined:
    Sep 6, 2020
    Posts:
    6
    Hey can you tell me how to baked the animation because using fbx exporter doesnt work for animation clips