Search Unity

Copy animation from one skeleton to another

Discussion in 'Animation' started by ChanzDog, Dec 13, 2019.

  1. ChanzDog

    ChanzDog

    Joined:
    Sep 28, 2017
    Posts:
    43
    I am reverse engineering an old game file format and importing the assets into Unity. I am currently working on skeletal animation and and have established a pipeline from the original files to a C# extractor to an intermediate format and then finally imported into Unity. Everything working correctly:

    1. Mesh is created via script.
    2. Skinned mesh renderer object is created with bone hierarchy and bone weights and poses are set. Prefab asset is saved.
    3. Animation clip is created via script

    The entire process is automated as I am programmer and definitely lack artistic talent.

    The problem I am having now is that some of the models reuse animations. For example, a lot of the character races use the same animation pool. Some other NPC models do as well such as a Rhino and Brontotherium (fantasy rhino creature). The problem is that although their skeletons are likely the same heirarchy, the bones have different names. So my animation clips may try to set the position of the bone RHI_HEAD but this model has a BTM_HEAD.

    What I want is a way to copy the animation to be used by this other skeleton without the restriction on the name. I could just rename the BTM skeleton bones to correspond with the rhino skeleton bones but this doesn't solve the problem as this is a relatively simple case.

    I have looked a bit at animation retargeting but it says it deal with humanoid skeletons. Another thing I considered was simply creating another animation copy by replacing all of the RHI with BTM so that it would work with the other skeleton, but then I would have two animations. I'd really like to use one animation and its values for the bone hierarchy with another skeleton. Is this possible?
     
  2. ChanzDog

    ChanzDog

    Joined:
    Sep 28, 2017
    Posts:
    43
    Additional info, the way I set up my curves by linking the full bone path. For example:

    RHI_ROOT/RHI_PELVIS/RHI_WAIST/RHI_CHEST/RHI_SHOULDER_R/

    If there was a way I could set up this relationship not using specific bone names but instead based on hierarchy, that would be way better and would solve my issue.
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Unity's Humanoid rigs handle this by using an Avatar to define a standard set of bones. Each model determines how its bone names match up to the standard bones and various other stuff about how muscle definitions correspond to bone rotations so that animations can animate the muscles of any Humanoid which can use its Avatar to determine how to apply that to the actual bones.

    Your use case sounds similar, though if your hierarchies are actually the same then you obviously don't need muscle definition stuff for retargeting (which is good, because I imagine that would be pretty complex to implement).
     
  4. ChanzDog

    ChanzDog

    Joined:
    Sep 28, 2017
    Posts:
    43
    @Kybernetik Thanks for the reply. Avatars look useful but how applicable is this to non humanoid skeletons, for example, a rhino.
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Humanoid avatars are not directly applicable. I meant that you would use the same concept to make your own Avatar class suited to your hierarchy structure.
     
  6. ChanzDog

    ChanzDog

    Joined:
    Sep 28, 2017
    Posts:
    43
    @Kybernetik Does your Animancer plugin help in any way with this issue? I am also looking for a better override animation controller which I know your asset provides.
     
  7. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Unfortunately not. Retargeting and Avatars and stuff is all handled under the hood by the Playables API so Animancer won't give you anything different from Animator Controllers in that area. It only deals with AnimationClips as a whole, not their internal details like which bones to apply which curves to.
     
    ROBYER1 likes this.