In this tutorial we are going to take a character with animation already applied to it and add a prop. We’re using a character with a motion called “shooting gun” from the Mixamo website. This piece of animation consists of a character reaching for a gun attached to his/her side, shooting it, and then putting it back. The only problem is there is no gun, just the character and motion.

We’ll start by creating a new scene in Maya. Your character and motion should be downloaded in the FBX format from the Mixamo website. Import your character into the Maya scene. At this point we need our gun prop.
To get a gun there are several options, you can model it yourself or get one from a website which is what we’ll be doing. The gun shown here is from turbosquid.com and has been assigned a red material to make it easy to see. Once the gun has been imported into the scene you will need to scale it and position it however you want.

With this animation, no matter how I place the gun, the characters hand isn’t reaching far enough to grab it. It would seem like the animation needs to be adjusted a little. The best way to do this in Maya is with animation layers. This is fully explored in our Maya Layers Tutorial which can be found at http://www.mixamo.com/c/tutorials . Once we have the hand moving close enough to the body, we can position the gun in a good location to be grabbed. One method that can make everything easy to keep track of is to have a gun holster attached as well. This way you will visually have a reference point for where the hand should be landing.

Now, how do we make the gun move with the hand like it is being held? At first, parenting may seem like the best solution and in many situations it would work. However, the gun really has two parents during this animation. Before and after the gun is fired, it is attached to the side of the character and would ideally be a child of the hips. Once the gun is grabbed, it should become a child of the hand.
We can parent the gun to either of these joints but not both at different points on the timeline. We want to be able to set a key that sets whether the gun is a child of the hips or the hand. Although we can’t key what its parent is, we can mimic the behavior with something that can be keyed, namely a parent constraint.
A parent constraint is a node that feeds data into an object’s transform values so that the object behaves as if it is parented to something, even though it is not. Because the child-parent behavior is being simulated, the object behaving as the child is not necessarily in the same hierarchy as the object behaving as the parent, it’s just acting like it is. The best part of the parent constraint is that it can be turned on and off and have those values key framed. This means we can have multiple parent constraints applied to one object and key frame when they are on and off.
Let’s try and implement this. While on the first frame, position the gun where you want it on your character. Now select the hip joint and then the gun (it is very important that you select them in this order). In the Animation menu select Constrain -> Parent. Use the default settings and then click apply.

Now if you press play, you will see the gun stick to your characters side but it won’t move with the hand. This is a good start because the gun is not floating, but reacting as if it is attached to the character. Now we need to add a second constraint that corresponds to the hand. It is important that you don’t add the constraint on the first frame, as that will provide an incorrect offset for the gun to move with, relative to the hand. Instead, move to the frame where the hand is all the way on the gun and add the constraint with the wrist joint.
At this time if you scrub through the animation, you will see the gun behaving oddly. This is because it is being driven by two parents. In the gun’s channel box, under the shape node, you should see another node with the word parentConstraint in it. If you click this node it will reveal the settings for the guns parent constraint. You should see the two parents of the gun, each with a weight of 1. If you set one of them to 0, it will turn that parent off.

On the first frame, key the value of the hip constraint at 1 and the hand constraint at 0. Key the same values on the frame before the character should lift the gun. On the next frame (the one you were on when applying the wrist constraint) switch the values for the parent constraints so that the hand has a weight of 1 and the hips have a weight of 0.
Right now the character should be picking up the gun shooting, but not putting the gun back. We’ll have to switch the constraints again when the character has his/her hand at the same location as when we switched the constraints the first time. Be warned that if you switch the constraints when the gun is not yet back, it will cause the gun to jump to its hip position. If the gun is fairly near, the jump will be trivial. Once you have set those keys for the constraints, your character should be lifting the gun from his/her side, shooting it and putting it back.

