Search Unity

Possible bug with humanoid rig and multi-parent constraint?

Discussion in 'Animation Rigging' started by SpiccyMayonnaise, Apr 12, 2020.

  1. SpiccyMayonnaise

    SpiccyMayonnaise

    Joined:
    May 10, 2018
    Posts:
    22
    I'm on 2019.3.6 with the latest version of the Animation Rigging package (0.2.6).

    Whenever I try to use a multi-parent constraint or multi-position constraint with a child of the animator root as the constrained object and a skeleton bone as the source object, the root just starts travelling infinitely in one direction.

    I'm pretty sure this has something to do with the humanoid type rig on my character, because I didn't get this problem when it was set to generic. Am I doing something wrong or is this genuinely a bug?
     
    AldeRoberge likes this.
  2. SpiccyMayonnaise

    SpiccyMayonnaise

    Joined:
    May 10, 2018
    Posts:
    22
    Update: Further testing has revealed that the problem only occurs when trying to constrain direct children of the animator. Grandchildren can be constrained with expected behaviour. Also, the sourceobject does not have to be set to a skeleton bone directly, objects constrained to a skeleton bone can also invoke the problem.
     
  3. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
  4. SpiccyMayonnaise

    SpiccyMayonnaise

    Joined:
    May 10, 2018
    Posts:
    22
    Sent! I figured out that it was a combination of a humanoid rig and a translation on the parent of the animator.
     
  5. HonzaMD

    HonzaMD

    Joined:
    Feb 9, 2020
    Posts:
    1
    Hello, I probably ran in the same issue, how it resolved? I have multi-position constraint affecting hips on humanoid ch. Flies away even if it's turned off.

    Thank you for any help
     
  6. SpiccyMayonnaise

    SpiccyMayonnaise

    Joined:
    May 10, 2018
    Posts:
    22
    An official fix for the bug hasn't been addressed yet, my bug report went nowhere.

    As for how you can work around it, assuming that your hips are a direct child of the animator, I'd suggest putting your hips transform as a child of another transform (maybe call it "skeleton"?), so that you aren't constraing a direct child of the animator.


    For anyone else checking this thread in the future, just make sure that you aren't constraining direct children of a gameobject that has an animator on it and you should be good. Put your constrained objects inside of an empty transform or similar so that they are no longer direct children.
     
    theawesomeshaz, DrBoum and HonzaMD like this.
  7. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi, I'm not sure we ever received your bug report actually :(
    Do you mind sending a link to the issue tracker, or the case number so I can look it up?
     
  8. DrBoum

    DrBoum

    Joined:
    Apr 19, 2020
    Posts:
    26
    i have an issue, on 2019.4.0f1 LTS with Animation rigging package 0.2.6, that i believe is very similar,
    i used the female model on starter kit synty studios and on a custom model and i could reproduce it,
    i don't know how to use the report bug feature so i will do that here.

    My issue is that the character was sent forward without any reason when he had constraints like multi aim and multi parent/position (potentially all the other "multi" constraints are affected)
    here is the reproduction steps:
    1. import a 3D model (i used the "SM_Character_Female_01" from the "starter kit synty studios" ,the first search result on the asset store) on the project.
    2. put the model to Humanoid and create the avatar definition
    3. create an empty gameobject. let's call it "heroineParent".
    4. Reset the transform of that "heroineParent" we just created.
    5. on the Z axis, put a positive value, this will make the object go in the Z axis
    6. put the 3D model you imported earlier into the scene as a child of the "HeroineParent".
    7. create a rig builder on the added model root (it should have the animator component), lets call that gameobject "the heroine" from now on.
    8. Uncheck root motion on "the heroine" animator component.
    9. create an empty child gameobject of "the heroine" and call it "RigLayer".
    10. add a new rig component to that "RigLayer".
    11. create an empty children to that "RigLayer"
    12. on that children add a component "Multi-Aim Constraint".
    13. create an empty children of "the heroine and lets call it "ConstrainedGameobject"
    14. back to the gameobject that has our "multi-aim constraint", drag the "ConstrainedGameobject" on the constrained Object Property
    15. now add "the heroine" to the source object (or anything else really).
    16. reference the "RigLayer" to "the heroine" RigBuilder in the rig layers property
    17. Press play
     
    Last edited: Jun 29, 2020
  9. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Thank you for that repro DrBoum.
    I found the associated bug you reported in our database and started looking at it.
    You can monitor it here: https://issuetracker.unity3d.com/product/unity/issues/guid/1259490/

    I have a local fix that solves the issue, but I would like to make sure it holds up. Most issues we find with humanoid characters are in Unity core animation c# jobs, so you can look forward for a fix to this issue in an upcoming Unity release.
     
    DrBoum likes this.
  10. DrBoum

    DrBoum

    Joined:
    Apr 19, 2020
    Posts:
    26
    thank you for your fast answer, for the workaround props to SpicyMayonaise what he said, is avoiding your source gameobject to be a direct child of the Gameobject containing the animator component, worked for me.
    i have a side question on the animation rigging constraints. currently we need to specify the source at editor time it is not very practical when you instantiate the gameobjects at runtime. is there any plan to be able to switch sources at runtime?
     
    Last edited: Jun 30, 2020
  11. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi,

    Short answer: no.

    Longer answer:
    Animation Rigging builds a Playable Graph that is evaluated by the animation system and processes Transforms directly in the animation threads. In order for that to be performant, animation c# jobs bind Transforms in the animation stream and therefore, changing these means you need to recreate the graph.

    You have several options in order to do what you want:

    You can rebuild the Animation Rigging graph (by calling `RigBuilder.Build`) with the new parameters which will ensure the PlayableGraph has the newest values. However, I would be cautious in calling that too often, as it can be a costly operation.

    Multi constraints have several sources to cover these cases. So, you could create placeholder source game objects to control your multi-aim constraint with and change weights to cycle from one to the other. Of course that means you'd need to also use these placeholder game object as parent to whatever you'd want to instantiate.

    Hoping this helps!
     
  12. mail_unity333

    mail_unity333

    Joined:
    Mar 31, 2020
    Posts:
    2
    The workaround did not work for me and this issue still happening with me event though it says it was fixed
     
  13. Docboy

    Docboy

    Joined:
    Sep 11, 2013
    Posts:
    14
    Have the same problem here, and I think it could be the script execution order, I mean that, the ParentConstraint gets the position of the bone before the animator sets it, so the position got is the original position without animation, the problem is we don't have acces to modify the execution order of these two components
     
  14. adishee

    adishee

    Joined:
    Jun 2, 2020
    Posts:
    8
    Same, this workaround didn't work for me.
     
  15. lucidtripper

    lucidtripper

    Joined:
    Aug 3, 2017
    Posts:
    24
    Multi-Position Constraint does nothing - I have a main camera I want to shift it smoothly around different moving objects in a scene - but no response - moving the weights does nothing - odd?