Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Blender to Unity: Can I keep just the original keyframes for only the animated bones?

Discussion in 'Asset Importing & Exporting' started by TwiiK, Dec 26, 2020.

  1. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I'm trying my hand at animation in Blender. I've never really animated anything before and the last time was like 10 years ago in 3ds Max so for all intents and purposes I'm a complete beginner. As a learning exercise I want to import a model with 2 animations into Unity: The first is a 1 frame idle animation (a static pose) and the second is a 20 frame long looping walking animation.

    I'm doing this because before I proceed with this I want to make sure that everything I feel is wrong or less than ideal is in fact due to limitations in the software and not due to me doing it improperly. So far I feel there is a lot that is wrong or less than ideal with my workflow.

    My frustrations so far are:
    1. Do I have to bake the animation to get it into Unity or is that a Blender limitation? I don't get the concept of baking an animation. It seems extremely counter-intuitive to me. My test walking animation is just 12 keyframes in total for 4 bones where the character is just swinging his arms and legs back and fourth. But when I get the animation into Unity there are way more keyframes than 12 due to baking and subsequently animation compression in Unity. Surely just importing the 12 original keyframes is more optimized than generating a whole bunch of new keyframes at fixed intervals and then trying to compress them away after?
    2. If I don't have Force Start/End Keying selected in the Blender FBX export then my 1 frame idle animation is not imported into Unity, but if I select Force Start/End Keying then I get keyframes for every single bone in my rig, not just the animated ones. Surely this is moronic and has to be avoidable in some way?
    3. In Unity I can create what I assume are much more optimized animations by duplicating the imported animations so that I can edit them in Unity and then manually deleting all the unnecessary keyframes for the bones that aren't animated as well as the inbetween keyframes created by the animation baking / compression. Surely I'm not meant to be doing this? There has to be a way to make this happen automatically?
    4. One last Blender specific issue I'm having is that if I don't set a keyframe for all my bones at the start of my animations then when I switch between the animations in Blender the animations overlap each other, ie. the animated bones from one animation remain when I switch to another animation. I have to reset all the bone transforms after switching every time. Again, surely there has to be a way to fix this without having to keyframe every single bone?
    So what's going on here? Are these limitations with Blender? With the FBX file format? Or does it just have to be this way for some obscure technical reason? I haven't looked into where would be the most suited place for me to ask such questions with regards to Blender specifically as I'm not familiar with the community there yet.

    I've looked at every single tutorial I could find on this topic, but nobody even mentions this. Maybe they know it has to be this way or they just don't care enough to fix it. I at least feel like this is 100% wrong and needs to be fixed, but if I know it's not fixable then that's of course fine as well because then it's not up to me to do anything about it.
     
    Last edited: Dec 26, 2020
  2. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Ref. point 3 above: Duplicating the walking animation and deleting all the keyframes for the unanimated bones and the inbetween keyframes for the animated ones reduces the size of the animation file from 833kb to 23kb and in turn gives me a 100% 1:1 animation with what I had in Blender compared to the interpolated/compressed animation I would have otherwise.

    There's no way this is the expected/accepted behavior? There has to be a way to have it behave this way automatically on export/import?

    How can this be seen as animation compression or keyframe reduction when it adds 500-1000-2000% more keyframes than I had originally and increases the size of my animation file 40-fold?
     
  3. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I will proceed under the assumption that this is how it has to be due to technical limitations or whatnot, but comparing this to 2d workflows this feels to me like exporting a PNG or other lossless file format and getting a JPG as a result.
     
  4. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    Baking can be ignored if the Blender animation was made using forward kinematics. With IK- I am not so sure. IK rigs do not transfer between programs and as the result, IK animations need a lot of frames to be properly represented. You can try keyframing the animated bones manually using "Visual Location and Rotation" keying set (represents the end result of all constraints), but you have to preview results with IK turned off, since situations trivial for IK (like shifting character center of mass while the feet stay in place) will need many extra keyframes to work as FK. By the way, are your animation assets in Unity in Blender format or *.FBX?
     
  5. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    .fbx. I tried just importing the blender files directly to speed up the iteration time, but I could never get that to work properly and there was almost no settings to tweak. With the normal FBX exporter in Blender I've experimented with every single setting until I managed to fix every issue I was having, but the animation baking didn't make sense to me, at least not initially.

    Now after following more rigging and animation tutorials and trying to make some actual animations and not just test animations I experienced what you've described here and I think I now understand more or the process and the limitations with it. Now that I have a more complex rig the bones/controllers/drivers that I'm using to create the animations aren't the same bones that get exported to Unity so Blender needs to "bake" the animation from my controllers down into the deform bones, I guess. I also have IK etc. setup in Blender like you mention here. And I've had to recreate that same IK in Unity using the Animation Rigging package due to my particular needs.

    I'm at least working under the assumption that this is how it needs to be, but I will remain critical of the process and see if it can be improved upon. :p
     
  6. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    I see; with direct export to *.fbx you at least have the option to turn off animation baking, should you use Visual Keying approach. (I suspect that *.blend to Unity will force baking by default, since this is the same *.fbx export, only running on background with unknown settings)
     
  7. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    When I turn of animation baking in Blender then no animations are exported at all as far as I can tell. All the animation export options are disabled then. I have no idea if other applications behave differently or if I'm doing something wrong in Blender, but after a few hours of googling I assumed that was how it had to be, ie. baking is the only way to export animations from Blender.
     
  8. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    Hmm, sorry then. I expected there should be the way to export only those keyframes you set manually; it is weird if there is none