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

Retargeting humanoid animation at runtime when changing the Avatar?

Discussion in 'Animation' started by bart_artanim, Jan 29, 2021.

  1. bart_artanim

    bart_artanim

    Joined:
    Jul 18, 2018
    Posts:
    19
    I have a humanoid avatar set up with an animation controller, playing out some animation. What I would like to support is a resizing of the avatar in height.

    I can currently make my changes to the underlying skeleton via the AvatarBuilder.BuildHumanAvatar API. Changing the T-Pose bone/joint positions in the description and then generating a new Avatar object works fine.

    However, when applying this new/updated Avatar to the Animator, it seems that the retargeting doesn't fully account for the changed sizes, in particular where the hip is concerned. If for example I increase the length of the legs, this is taken into account, but results in an animation where knees are bending to accommodate for the longer legs. What I would like to see happen is for the hip-height to be raised.

    If on the other hand I make my changes to the imported avatar via the Avatar Configuration window, and then go and play the animation, the result is just fine. So it seems there is something in the animation retargeting which does take place in the latter case, but which doesn't happen at runtime. Perhaps I'm missing out on an API call or some form of "refresh", but I can't seem to find anything related.

    If anyone has an idea of what I might be forgetting I would love to hear it.
     
  2. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,033
    I think I looked into it before and wasn't able to make it work. If I recall the problem is that the avatarbuilder api doesn't take into account the humanoid muscles settings that is what drive the retargeting.
    I could be wrong because it's been a couple of years since I tried it, in the end I ended up using premade bodies with different bone builds to swap at runtime as a workaround.
    The only thing you could try is call the animator.rebind method.
     
  3. bart_artanim

    bart_artanim

    Joined:
    Jul 18, 2018
    Posts:
    19
    I was afraid that would be the answer. Unfortunately I am in a situation where I want to create loads of variety, which makes premade bodies less practical. So let's see if I can avoid that.

    Thanks for the Rebind tip. I'll have a look what that gets me.
     
  4. bart_artanim

    bart_artanim

    Joined:
    Jul 18, 2018
    Posts:
    19
    In the end I have managed to make this work. The key issue I found is to make sure that your resized avatar's T-Pose definition does have the hip joint's position adjusted in such a manner that the feet are planted on the ground (i.e. y being 0). So if you make your legs shorter, lower the hip accordingly, and of course move it it in the other direction when giving it longer legs. This T-Pose definition which is captured within the SkeletonBone array in the HumanDescription is key to the rest of the animation functioning properly.
     
    Ninivekha likes this.
  5. BehnamMbagheri

    BehnamMbagheri

    Joined:
    Aug 4, 2020
    Posts:
    4
    hi @bart_artanim
    I have your problem too..I create an avatar in daz that can resize his height but when I change it to small height and assign animation to it .it get deformed ..
    can you tell me how solved this problem??
    Thanks in advance for your help
     

    Attached Files: