Using Inverse Kinematic Rigs for a First-Person Shooter in Unity 3D
Keeping Your Hands On Your Weapon

So, here’s a bit of a problem. I have an idle animation for my player holding a pistol, and I’ve placed a weapon prop in the player’s hands. But if I pan away from my hands and the weapon, they leave my view. It doesn’t really feel like aiming. If I set my weapon as a child of the camera, the gun will move along with my aim, but my hands are stuck in the place where the animation has left them.
To solve this problem, I need to set up an Inverse Kinematics Two-Bone Constraint. Don’t worry if those terms seem beyond comprehension. You’ll see what we’re up to pretty quickly. The gist is, we’re going to create targets for our hands to stick to, and other targets to guide the kinematics of the model’s rigging so our player moves naturally as the gun follows our aim.
The first step is to create the targets for each hand and elbow. Create an empty object in your Hierarchy called IK_Rig, and four child objects within the IK rig called L_Hand, R_Hand, L_Hint, and R_Hint.

Once you have your rig set up, place a Rig Builder component on the root Player object, and place the rig in the slot provided.

Next, on the L_Hand and R_Hand objects, place the IK Two Bone Constraint component. In the blanks provided we’ll be placing the bones of our player’s arms and hands, starting with the Upper Arm in the Root and the Hand in the Tip:

We’ll also place the L_Hand object itself in the Source Objects > Target spot, and the L_Hint in the Hint spot.
The Tip will stick to the Target, and the joint in between the Root and the Mid will bend toward the Hint when necessary to accommodate the movement of the Tip.
Now, all we need to do is move the Target (the L_Hand and R_Hand objects) into the proper position and rotation to appear to be holding the prop.
This has to be done from Play mode, as the character won’t apply it’s IK component in the Edit mode. BE SURE TO RECORD YOUR TARGET LOCATIONS BEFORE LEAVING PLAY MODE. Once you have a look you like, exit play mode and enter the coordinates for rotation and position for each target into their respective transforms. If you had to adjust the Hints to get the elbows bending correctly, make sure to readjust those as well.

Keep in mind that this is a FPS view, so the best angle to refer to is the game view. The trigger finger doesn’t need to line up perfectly, because the player won’t see it.

And there we have it. Your hands are accurately holding your prop, and your arms will move in a more or less realistic fashion wherever the prop happens to go. It’ll even make your arms kick a little when the weapon animation bucks.

That’s all for today. See you again tomorrow for the next progress update.