Multi-Parent Constraint with a Humanoid rig

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:

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

Any suggestions for where I’m going wrong?

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!

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?

Hi,
Are you enabling ‘Sync Scene Values’ on the source object?

4729838--447944--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!

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?

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.

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).

Hi @simonbz I am also having issue with multi-parent contraint on a humanoid rig. In my case I am trying to avoid using root motion.

My character movement is controlled by a character controller and a script to manage input. I’ve setup a animator controller with 2D Freeform Directional param corresponding to the horizontal and vertical axes. I’ve 9 animations for the 8 directions + idle. I’ve unchecked root motion in the animator.

I added a rig with TWO two bones IK constraints. No problem.

Then I added a rig on top with a multi parent constraint. No problem.

Next I assigned my weapon ( which is a child of the character animator component object ) to the Constrained Object. No problem.

Then I assigned the object containing the multi parent constraint itself as source object. Now the character doesn’t move any more and only the idle and forward running animation will play, regardless of which button, WASD, I pressed.

I’ve updated to Animation Rigging 0.3.3 and Unity 2020.1.0b

Ok It’s fixed by making my weapon ( i.e. the Contrained Object) a child of the left clavical bone. I think the key point is the Constrained Object must be lower in parent-child tree than the source object ?

2 Likes

I cannot seem to get the multi parent constraint script to work.

This is a picture of the hierarchy of the character being controlled and animated:

Both the source objects have the Rig Transform component attached and I placed the sword (constrained object) underneath the source objects just in case. The AlienSoldierPlayer root prefab has the Animator component. The RigLayers (walk and run) are working just fine.

This isn’t a major deal since I can just do what I was originally planning on (which is change the parent of the constrained object based on whether or not the player is running or not) however I figured I would try and use the Multi Parent constraint since it seems purpose built for this situation.

Would appreciate any input!

Hey, from your picture it is not really clear where the RigBuilder and Rig components are located. The multi-parent constraint needs to be located underneath a Rig, which in turn needs to be located under a RigBuilder component. Typically, the RigBuilder would be attached to the same GameObject as your Animator. And the Rig components would be on RigWalkLayer and RigRunLayer. Which would mean that the Multi-Parent Constraint is not picked up by the system because it is underneath mixamorig:Hips. Moving only the Multi-Parent Constraint component to either layer or a completely new layer would solve this issue. Please be aware of the fact that if you make changes to the Rig Hierarchy and add constraints at runtime you need to rebuild the PlayableGraph at the RigBuilder to reflect the changes.

1 Like

Hi there, thank you for the speedy response. Placing the sword under one of the rig layers now has the sword moving in the same motion as the parent, I see now where I went wrong.

The Rig Builder is indeed attached to the root game object (AlienSoldier) which also has the Animator component attached. The sword (constrained) object is now nested under a new layer named “RigWeaponLayer”

I can see that now the multi parent constraint component is indeed animating/updating the swords position based on the source object, but the position and rotation are way off. Perhaps I’m misreading/missing something from the docs – I was assuming that if I had the rotation and position of the sword as default (0 for all rotation and position values, 1 for all scale values), it would act/animate as if it was a direct child of the source object that has a weight of 1.

As demonstrated in the screen shots, the sword position and rotation values update during play mode but not to the values of the 2HWeaponRun transform. The RigWeaponLayer has a weight of 1 as does the multi parent constraint.

6601306--750658--snip-run-parent.png

I suspect you want to set maintain offset to none. When this is turned on an offset will be kept on graph creation (when you enter play mode). In your case you do not want this. In later versions of animation rigging we set the default value to none.

1 Like

I also suddenly couldn’t move my player when adding this feature rig feature.
With your solution, the movements of the skeleton still had an impact on the constrained object, in my case a weapon I wanted to keep “stable”…
What worked for me was to keep the constrained object out of the body and just enable the Apply Root Motion on the animator.

Hello @simonbz , I use the Animation Rigging Package in my Project. I am initially only using the multi-parent-constraint to parent a Sword to the back of the character when not using the sword and parent to the hand of the character when using the sword.

I have properly assigned the target property, the source objects with the weight of BackRef initially 1 and that of the HandRef to 0, and also properly set up the Rigs and Rig Layers. I have set up a system to use the animation Events to trigger Methods and to adjust the weights if the sourceObjects on the multi-parent-constraint .And Infact all this was Fantastically working with a lot of performance. Thanks to the Animation Rigging Package.

Now the problem is I want several types of Swords as the user progresses throught the game. I am using the Game Foundation Package also, and it’s Inventory system to set up the properties of the Swords and find what type of sword the player currently has (lower power sword is progressively replaced by the higher power sword).

Therefore, no sword is in the Scene now. Then in the Script, I decide what sword to use, get it, Instantiate it with the position of the BackRef and the sibling of the multi-parent-constraint gameObject. Also, I assing the Instantiated Sword to the targetObject of the MPC(multi-parent-constraint), and all the reference fields of the Instantiated Sword too. The Sword is successfully Instantiated with the correct Position, Rotation and Parent. All the References were also Assinged correctly. I checked them in the Inspector.

When I pressed the Attack key before, it correctly played the Animation, the Animation event were fired, the weights of the MPC changed and the position of the Sword to the HandRef. And the same for putting the Sword also. But this was when the Sword was already in the Scene.

Now, when I Instantiate the Sword, I and press the Attack key, It does all the things as above, even changes the weights on the MPC (I double checked!). But the Sword doesn’t changes its position. Why?

I again isolated all the Sword Instantiation and placed the sword in the Scene and assigned all the Refs. I played the Scene and it Worked. The Sword got into the hands of the Character as before.

Why is this, does Animation Rigging doesn’t works on Instantiated Objects as Target.

I request a kind Help.
Regards
Harsh.

The above mentioned does not happen with only Instantiated objects. I tested and found that if we set the constrained object at runtime, via script, the Animation Rigging system does take this into account.

It means that we cannot change the constrained and sourceObjects at runtime?
Thanks.

I have a MultiParent constraint on an object and I also am trying to change the sourceObjects with script at runtime which is ignored. I’m using Unity 2021.1.28f and as you mentioned there is no longer a Sync button.

My object is not animating so why is it not syncing?
The MultiParentConstraint works if I set the source object before running but wont change after…

thank you so much man