3D Survival FPS Game

Adding a weapon for our player and working with IK Riggings

Now that we have our 3D player model active and it has it’s own idle animation with the hands up during game play. It is time to equip our player with an weapon and also have our IK model simulate the hands position to hold the gun, along with the gun recoil trigger the hand movement.

Downloading the Weapon From FileBase:

The pistol USP weapon asset that I will be using is sourced from FileBase on GameDevHQ, it is a great source of Unity help and also the library is quite intense.

Once you have download and imported the 3D weapon, we are going to be using the prefab version since the Filebase prefab is complete with animation, button triggered and sound/visual effects.

The prefab version is complete with sound and visual effects

Drag the gun prefab into the scene so we can start positioning it in the correct location in front of our camera.

The two different views of the weapon placement.

Working with Inverse Kinematic (IK) Riggings:

Before we start working with IK riggings, we need to first download the proper plugin for Unity called “Animation Rigging”. If you are working with pre Unity 2020, then the package would still be under “Preview testing” which you have to turn on to find this package.

To understand what IK riggings are, it is basically a skeletal invisible frame that helps refine the 3D animation of joints and positioning. As you can see the current position of our player’s hands don’t quite grasp the weapon handle. With IK rigging we are able to finely adjust the position so we can get that precise positioning that we want.

To start, we are first going to create a new empty game object called IK within our Player game object. Then within that IK component we are going to create 4 more empty game objects with the current names, “Left hand, right hand, left Hint, right Hint”.

The left and right hand are quite obvious, but for those who have worked with 3D modeling, a “Hint” is what limits or forces a certain joint movement. In this scenario, the left and right Hint will be focused on our elbow placement. Basically we are going to limit our elbow movement so that it bends correctly if our arms where to contract and isn’t going to bend awkwardly.

The teal orbs are the Left and Right Hints

Next within our Left and Right IK hands component, we are going to add the “Two Bone IK Constraints” component, this will control the IK movement.

Next we need to drag in our Bone structure from the 3D model. If you are using Filebase’s models, this would mean anything from the Arm down to the hand.

Root = Arm | Mid = Fore Arm | Tip = Hand

Once you have drag the corresponding components to the correct slots we will need to drag in the IK components as well. The Left IK hand goes into the Target slot, while the Hint goes with the Left Hint slot. Because now the Left hand is now linked to the 3D model left hand, In the play testing, if you move the IK left hand, the 3D model also follows.

In the next article we will discuss how to make the hand respond to recoil of the gun movement, and also how to get a precise grip of your hands 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
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.