Search Unity

Converting (Unity Made) Generic Animation Clip to Humanoid Clip

Discussion in 'Animation' started by Frostbite23, Apr 9, 2020.

  1. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Hello, as you can see by the title I am currently scratching my head on how to solve this issue (And have been for weeks). Before you write up a reply I know a similar question has been asked before, but this is different because I don't have a model that already has an animation on it.

    Instead, the animation is done and created inside of unity on a 'humanoid' model (using the built-in IK) and on recording it 'records' the transformations on each 'marked' joint. Building out the list and essentially creating your mess of keyframes into a legacy animation clip. (Then I just do a simple conversion to a generic clip via unticking the 'legacy' box on the clip). Simple and easy and it works. Heres proof.



    Uses the original Vive headset (plus the 2 controllers and 3 additional trackers) and it works perfectly fine provided that there are some inaccuracies here and there but anyways that's not what I'm here for.


    Here's the problem.


    In my game, I have these recorded mocap animations of course that will be used for different situations. However, the player can influence the AI and I need to use IK for this (I.e. pushing its hand or arm back). No physics ragdoll because it's too unstable for it.

    To my understanding, only the humanoid type supports IK. Yet humanoid and generic animation clips are completely different.

    Humanoid animation clips keyframe a bunch of muscle movements while with generic animations you can keyframe just the transformations (position, rotation, scale, etc.)

    So my question is, how can I convert my (unity made) generic animation clip to a humanoid animation clip? (I don't want to drop money on plugins for this).

    There is a chance I've grossly overlooked something, and that's possible since I spent a long time trying to figure this out. But simply putting the generic animation clip on my humanoid model won't work and I've tried, and I've also tried making a custom IK but failed.

    I have in the meantime a very crude solution that I'm not too happy with but it works somewhat decently where I have 2 models for my AI, the generic model with the animations on it for reference (invisible), and the humanoid model (visible) with IK enabled. I basically run the animation I need with an animator controller on the generic model and with the humanoid character, I do a mix of matching the position and rotation of each joint + IK on feet and hands to match the hands and feet of the generic model. It's not 100% accurate and it sometimes does glitch out but I somewhat maintain the IK feature and I can influence the AI as I need but this solution is very very rough and inconvenient.
     
    Last edited: Apr 9, 2020
  2. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
  3. wilsonillustration

    wilsonillustration

    Joined:
    Apr 2, 2019
    Posts:
    2
    I think that you've run into a core reason why Unity has been moving away from the Humanoid structure. Humanoid anims do include basic translations, rotations for the joints- but only as it follows a strict rig format. If the rig has extra bits, it does get quite complicated fast. The muscle movements are generally used to help a physics based rig maintain poses.

    I would recommend keeping the anim on a generic, but including the now standardized Animation Rigging setup. You can get the full IK set-up running within a few hours even on your own custom rig. Given the capture method you used (really cool BTW) the examples provided in the package manager and doumentation they seem like compatible structures. If there are any questions about it feel free to give me a holler.
     
    Frostbite23 likes this.
  4. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Hmmm never heard of the animation rigging from Unity, looks like its something brand new which is why I probably haven't seen it before. It seems so far after brushing through it that it will be similar to my crude solution but probably done better. I'll look into it and ill let you know when I succeeded/failed :p but thanks for mentioning it! Ill definitely look into it and see what I can do.
     
  5. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    I know you said you don't want to use plugins, but the only method I know of is Skele's dae exporter which can convert .anims for a character and then those dae can be changed into humanoid.

    also there's a new IK solution on github
    https://github.com/filgreen3/Paper-Generic-IK

    anyway, those animations looks great. once I tried to use IK to reproduce animations and the result wasn't anywhere near that good.
     
    Last edited: Apr 15, 2020
  6. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    The IK is actually just using Unity's classic Mechanim IK, it does a decent job at times but for the legs, for example, I had to solve where the knees would be since the built in IK wasn't doing a good job there. But 80% of the Motion Capture I'm doing is just using the Mechanim IK.

    In the future, though I would love to take another stab at making my own IK again but its tough to wrap my head around the math and concepts.
     
    Last edited: Apr 16, 2020
  7. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Alright sorry for a late update but I managed to learn about the 'Animation Rigging' tool and I gotta tell ya, its amazing and I'm so glad you brought my attention to it! It's fantastic, I haven't had any issues with it and it seems to be working flawlessly even for a 'preview' package, but thank you soo much!
     
  8. nadunliyanage

    nadunliyanage

    Joined:
    Feb 16, 2021
    Posts:
    2
    did you get rid of the Humanoid structure? and moved to generic? In order to achieve best results in animation rigging?
     
  9. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Very, very, very late reply but for the sake of future people coming on to this thread...

    Yes, I ditched the humanoid rig structure completely and stuck to generic for that project at the time. I only stuck with the humanoid rigging at the time because it allowed me to leverage mechanim IK, but with the animation rigging package that was brought to my attention in this thread and learning about it, I was basically able to ditch the humanoid/mechanim IK completely. Building my own custom rig using the animation rigging package allowed me to have the IK features I wanted, and also let me stay in the "generic" animation structure. Which meant I could get rid of my weird and hacky "conversion" solution that I described in the first post of this thread. No need to worry about moving in and out of a humanoid to a generic or generic to humanoid animation rig.
     
    aurelioprovedo and petrknedlik3 like this.