top of page
Writer's pictureDaniel Henshaw

[28/03/2022] Basic Inverse Kinematics Gun & Head

I created a basic IK gun holding system. For this system I decided to use unity's 'Animation Rigging' package which I downloaded from the package manager. I decided to use this system because I knew that creating an IK system from scratch with code would be very difficult and take too long to get working before our deadline.


Firstly, I attached a 'Rig Builder' component onto my player object.

On this 'Rig Builder' component I attached the 'Rig Layers'


Secondly, I created 'Rig Layers' by creating an empty game object and adding a 'Rig' component attached. These layers contain child components which have constraint components attached onto them.


Head Aim:

For the head IK system I needed a object to constrain the head look orientation too. I decided to create a empty game object on my camera called 'AimLookAt'. This game object is positioned 20 units on the Z axis which makes it so the player looks straight forward at where the camera is angled.


The child component inside of the layer object uses a 'Multi-Aim Constraint' which constrains the heads rotation with the 'AimLookAt' component.


Hand IK:

For the player Hand IK I had to create game objects for a hand position/rotation reference. This reference was placed as a child of the weapon. I used two reference objects for each arm.


The child component inside of the layer object uses a 'Two Bone IK Constraint' which constrains the arms bones to the target reference object. When I tested this at first the arms seemed to glitch inside of the players torso. In order to fix this I added a hint game object. This object is placed inside of the arm bone and it tells the constraint where the elbow should bend and be positioned.


Time lapse:


Evaluation:

Using the Animation Rigging was a perfect way of creating a working basic inverse kinematic system. It is very versatile and can be used in multiple ways. If I was to make a similar game I would most likely use the same IK system however, I would definitely change how the players forward kinematic animations work. This is because the arms don't stay firmly on the gun and seem to move with the players run animation. Most games use a method where the player arms are separate from the body. This allows the players arms to visible but disables animations on them only allowing the IK animations to work.

Comments


bottom of page