Nerd For Tech
Published in

Nerd For Tech

IK Weapon System in Unity

3rd Person Zombie Shooter

Objective: Create a IK weapon system

First of all Install the Animation Rigging from the Windows < Package Manager.

Then add a Rig Builder component inside your Player gameobject Which needs to be the Parent. This won’t work if it is a child of another gameobject.

Now create a new Gameobject IK and add a Rig component inside it. Make sure to drag this gameobject to the Rig Builder inside Player so that it knows this is a Gameobject with Rig.

Now create four gameobjects, each defining either hand or a Hint. Hand refer to the place which we want to force an IK on and Hint refers to a pole vector which defines where and in which direction the elbow bends in this case.

Create a two new gameobjects which will define the hand position so that we control our hand according to our gun rather than controlling gun according to our hand.

Now create a new script SmoothDamp script which will then lerp so that the hand always goes to the target position. This script will be attached to the Hand Ik and the target will be the hand position inside USP for either hand.

Then we add a Two Bone IK Constraint component to the Hand to create the desired movement of hand.

we place the Hand to the target which describes the target to move and define Hint to hint.

And then we add Three rigs of our gameobject leading up to the Hand.

And then position the Hand and Hint as follows, Hand above for Hand movement and Hint below to define elbow movement and rotation direction.

And we can now animate the Hand for Reload and such as above and the hand is always fixed to the Hand position defined on USP unless moved.



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