Holding Weapon with IK Pt.01- Game Dev Series 128

Objective: using IK (Inverse Kinematics) to control the hand position of Player.

We have created a well functional Player moving method and attacking system. In this article, we would give our Player a good looking skin and make his hands workable with rigging system.

Make your Player has skin

To make our Player looks alive, the first step is giving it a model. You can download it from Mixamo.com, or use a GameDevHQ model like me.

Once imported the model, adding the Character Controller component, player movement script, and shooting function script.
Your Player should moving smoothly with these components.

Inverse Kinematics

Now we need to make its hand functional. We will use a package called Animation Rigging to create IK.
IK means Inverse Kinematics, which is a way to move the animation character base on child objects. When using IK to move an animation character, we usually control the end of limb to make the rest of limb following, and that is “Inverse”.

Open Package Manager and check “Show preview packages” from the Advanced menu.

Then install Animation Rigging.

After installation, create an empty object under Player, and name it “IK”. This would be the base system controller of Player. And add a Rig component to it.

Then create 4 additional gameobjects under IK, and name it as the image below.

The first 2 would be easy to understand, which we will set it as hand position in the upcoming content.
And the “Hint” for both hands would be an anchor point to make arms of Player twisted in a proper way.

Once finished setting IK, select Player gameobject and add a Rig Builder component to it, and drag IK onto it.

With these Rig components, we can make the hands moving to the position we want.

Two Bone IK Constraint

Select both left and right hand gameobjects under IK, and add “Two Bone IK Constraint” to them.

You should see the component needs some part of model to work.
It requires 3 parts of model, a target position, and a hint position.

First let’s start with left hand.
Locate the angle object of left arm in Hierarchy. Then drag LeftArm, LeftForeArm, and LeftHand model objects to Root, Mid, and Tip in component.
If your model is not separate theses parts as mine, then just drag the parts from the end of arm to Tip first, and all the way up to 3 parts to Mid and Root in order.

Then drag the L_Hand and L_Hint from IK to this component.

And do the same setting to right hand.

The next is adjusting the position of Target and Hint.
Select L_Hand and L_Hint, and adjust them to a proper place on the left hand side of Player.
Notice that L_Hint would be better is placing it besides left knee of Player, which would be an anchor point to left elbow.

Orange circle: L_Hand; Orange diamond: L_Hint

And adjust the opposite position to R_Hand and R_Hint.

Once done, Player’s hands should snap to the place we want.

This would be the basic setting of Player.
In the next article, we will make its hands snapped to the weapon.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store