Search Unity

Multi-Parent Constraint with a Humanoid rig

Discussion in 'Animation Previews' started by ShedworksDan, May 30, 2019.

  1. ShedworksDan

    ShedworksDan

    Joined:
    Oct 8, 2013
    Posts:
    1
    I'm trying to use a Multi-Parent Constraint that will allow a character to hold an object in their hands. I set everything up using the sword example scene from the package as a reference, putting the hand bones from the rig in the list of source objects, like so:

    upload_2019-5-30_17-11-25.png

    When I run my game, I get the following warnings on the character's Animator and the constrained transform doesn't move at all:

    upload_2019-5-30_17-10-40.png

    Any suggestions for where I'm going wrong?
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    52
    Hi,

    Is your FishingPole game object child of the Animator hierarchy? In order for a game object to be animated by Animation Rigging, it needs to be included in the animated hierarchy.

    As for the binding warnings, you can safely ignore those. While it's true transforms cannot be animated in a humanoid hierarchy, animation rigging applies as a post-process to animation after humanoid curves have been converted back to transforms. We need to update this warning eventually to take that into account!
     
  3. Sholz

    Sholz

    Joined:
    Dec 12, 2016
    Posts:
    13

    Multi-Aim Constraint not Updating with Source Objects Positions
    Hello sir, I also want use the Multi-Aim Constraint on a model. its is working well except that the "Constrained Object " does not follow/Update with the position of the "Source Objects" (in realtime/update) in playmode...

    It only just adjusts on start only which is weird because when I apply it in the demo scenes the "Constrained Object " follows/updates position with the "Source Objects".

    All is ticked under the settings are and Weight is 1. Any tips/advice?
     
  4. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    52
    Hi,
    Are you enabling 'Sync Scene Values' on the source object?

    Screen Shot 2019-07-09 at 3.51.18 PM.png

    Doing so will make the Multi Aim constraint update from scene values. You usually want to toggle this option when you control your source object position from script as opposed to reading from the stream values when the source object position is animated in the Animator.

    This option will disappear from the animation rigging package in Unity 2019.2, as we're automatically reading from the scene when values are not animated.

    Hope this helps!
     
  5. TP-Fab

    TP-Fab

    Joined:
    Jul 10, 2019
    Posts:
    2
    Hi @simonbz I'm having issues with that too: how would you recommend dealing with multiple items and multiple actors in one scene?

    I can see a couple of ways of doing this currently:

    - Items are passive, each actor owns a multi-parent constraint. When ActorA grabs ItemA, ItemA is added to ActorA's hierarchy and ActorA's multi-parent's constrained object is set to ItemA. Con: that defeats the purpose of the constraint (not having to set the item as child of another GameObject)

    - Each item has a multi-parent constraint and a fake source object (like recommended for the multi-aim). The source object follows the holder via custom script. Con: that means adding an Animation Controller to every single item in the game (with a valid animator!), and the source follow might already do everything needed without the need for constraints?

    - Second option optimization: instantiate a pool of "Interaction" game objects with a multi-parent constraint and a custom source object. Fetch an Interaction when needed (attach the item to it, and have the source follow the holder). That's not a drastic improvement though (just limits the amount of animator/rig/constraint combo to active actors count rather than items count).

    What do you recommend for such case?
     
    Last edited: Aug 7, 2019
  6. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    52
    Hi,

    Well, moving objects around in the animated hierarchy is a sure way of reducing performances in your game, so I would advise against it.

    Setting an Animator on your prop game object and having it read its parent transform from an other animated hierarchy will work, but you might read the parent transform one frame late. All separate animated hierarchies evaluate in multithreaded jobs and you'll only get the parent transform position on the next frame when you reevaluate the animation again.

    Alternatively, you could have a pool of props game objects set on the character animated hierarchy and toggle their visibility when an object is in use.

    If that's not an option, then, I would suggest falling back on a LateUpdate routine to adjust the global position and rotation of your prop game object based on the parent transform in the character hierarchy.
     
    Last edited: Aug 14, 2019
  7. TP-Fab

    TP-Fab

    Joined:
    Jul 10, 2019
    Posts:
    2
    Hi! ok then I guess all that'd be done without the multi-parent constraint: I'm simply going for a transform follow on LateUpdate at the moment, and that's good enough for my need (numerous actors and props, performance is more important than exact fidelity).