Creating a First-Person Reload Animation with an Inverse Kinematics Rig in Unity 3D
Today we’re going to be using the IK Rig we built yesterday to create a reload animation. The process is very simple, and if you’ve been reading along and are familiar with Unity’s animation system this should be a breeze.
The first thing we need is to create an empty animation (called “Reload”) and load it into the Animator for our prop. The transition into this animation will rely on a trigger parameter called “Reload.” The transition out will happen naturally with exit time.
With the prop selected, open the Animation window and select the Reload animation.
Then we need to add the position and rotation properties for all of the elements we’ll be animating. The prop object, the magazine clip object, the two hand position objects, and the upper receiver of the prop (mine is called “Top”).
The main object we need to manipulate first is the prop itself. Set the full animation to be about 2 seconds long and then enter Record mode.
In the first frame, move the upper receiver back — when this kind of pistol is out of ammo it won’t automatically return the upper receiver to the forward position until the clip is loaded .
Then select a frame somewhere around the half-second mark and move the weapon up, rotating it to face the player. We want to be able to see the bottom of the weapon where the clip will eject.
Now, we don want our left hand in the way of an ejecting magazine, so by this point (still the half-second mark) we also want to move the left hand position out of frame.
Advancing to 0:40 on the timeline, we’ll select our clip object and drop it out of the weapon.
Finally, at 1:00 let’s adjust the hand to be cupped under the magazine clip.
From here it is a simple process of copying all the animation frames and repeating them in reverse order on the back half of the animation. The clip and left hand rise back into place, the weapon tilts and moves away from the player back to its original position.
At this point you should have a roughly symmetrical dopesheet.
A few minor adjustments — we want the left hand to return to a slightly different position so it appears to be pushing the clip into place, and we also need to add a bit of “bounce” to the weapon itself to give the sense that the player is slamming that thing in there securely. We also need to return the upper receiver to its proper place. Along with some minor adjustments to the right hand so it stays where it should in relation to the weapon, and we have our final dopesheet:
Let’s take a look at the full animation:
Fantastic. Now all I have to do is fix that finger problem… which probably has to do with the model itself. Otherwise, this looks great.
Tomorrow I’ll have a full project review for the 3D FPS prototype so far.