Search Unity

Animation rig with non-root animator

Discussion in 'Animation Rigging' started by LudiKha, Oct 25, 2019.

  1. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    140
    My character controller is set up such that the animator is a child of the root object. Trying to set up the rig builder on the child, throws an error that prompts me to put the rig builder component on the root GO. By default, it requires the animator to be present there also, but overriding this and manually referencing the (child) Animator component, throws a number of "PropertyStreamHandle cannot be resolved" errors.

    Is it currently possible to use animation rigging with such a setup? If so, how do I set this up?

    Thanks,

    - K
     
  2. Jebtor

    Jebtor

    Unity Technologies

    Joined:
    Apr 18, 2018
    Posts:
    115
    The RigBuilder is only meant to work when it is on the same GameObject as the Animator. This should be enforced by the [RequireComponentTypeof()] attribute at the top of the RigBuilder component. Things will break when you are overriding the reference. However, it should be possible to set up a RigBuilder + Animator any where in the hierarchy.

    You can verify this by grabbing the Animation Rigging samples from the package manager. For any of the sample scenes you should be able to create an empty gameobject and child the root gameobject to it. The sample should still work the same after this.

    To help you better it would be great to have some more information. Could you specify what the error is you are getting when you have a setup with the rigbuilder on the child? We have had a bug with this in the past but it should be fixed in recent versions. Could you also provide us with the Unity version and Animation Rigging version (which can be found in the package manager) you are using?
     
  3. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    140
    I find it happens specifically when using animators using an avatar setup. If I initialize the rig on the root, and then reparent it to a different root transform, the problem doesn't occur. I suspect the error has something to do with the avatar rebuilding process, which expects the animator to be in the root.

    Unity version 2019.b7
    Animation rigging 2.0.3

    upload_2019-10-26_21-38-5.png
     
  4. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi Ragoo,

    This is a bug and is already tracked in our bug database.

    Here is the issue tracker link if you want to follow up on progress: https://issuetracker.unity3d.com/is...sted-animator-hierarchy-triggers-an-exception

    This is triggered because animation job handles in animation rigging are adding additional Transforms to the stream which were not in the original avatar. To work around this for now, you can try regenerating a generic avatar (that is considering you have a generic rig) like so:

    Screen Shot 2019-09-30 at 11.29.18 AM.png
     
    LudiKha likes this.
  5. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    140
    Thanks! For now, I've found a temporary workaround:
    1. Ensure the RigBuilder component is disabled before entering play mode
    2. Unparent the Rigbuilder/Animator transform
    3. Enable the RigBuilder component (so that it initializes/rebuilds)
    4. Wait one frame for the building to process (e.g. in a Coroutine)
    5. Reparent
    This also works if you want to edit the avatar in runtime (e.g. when you're programatically editing poses/proportions for character customization).
     
    ibernd likes this.
  6. ibernd

    ibernd

    Joined:
    Jun 24, 2019
    Posts:
    16
    For me that works only if i enter play mode before step 2.
    So its just a workaround for a single playmode run or did i miss something?
     
    Last edited: Nov 15, 2019
  7. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    This stops me in my tracks. Using humanoid rig with retargeted anim, back to default ik.
     
  8. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
  9. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    upload_2019-11-29_5-20-56.png

    2019.3.0f1 :(
     
    ibernd likes this.
  10. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi,

    We reproduced the same issue with humanoid characters when retesting. This is very unfortunate. While the initial fix did solve the issue for generic characters, it overlooked humanoid characters. We have opened a bug for the new issue: https://issuetracker.unity3d.com/is...ted-humanoid-animator-hierarchy-does-not-work

    I have written a fix for this and it should hopefully be available in previous Unity versions soon enough.

    Sorry about that!
     
    LudiKha, ibernd and pointcache like this.