Reload IK Animation
Objective: Custom reload IK animation for USP Glock.
This IK animation will focus on the USP game object which is a child of the USP_Pos, as shown below. Note the Hand_Position_L, Clip and Top for this IK animation.
To start create a new animation, Reload, in Gun_Animation folder. Select the USP object and open the animator window, dragging the new Reload animation into the animator. Create a transition to and from Idle to Reload, as shown below. Also create a new trigger parameter named Reload.
The Reload trigger is used as the condition for the Idle to Reload transition with has exit time unchecked and 0 duration. The Reload to Idle transition uses has exit time, i.e. checked, with 1.0 exit time and 0 duration. Note that the units for exit time are normalized, so 1.0 is the end of the animation.
Select the USP and open the animation window, selecting Reload animation from drop down menu. Next add properties for USP rotation and position. The full animation is shown below, but initially focus on the USP position and rotation. There are two key points for the USP, one at 0:30 and another at 1:30 seconds. The reload occurs between these times. There is a slight bump to the gun just after jamming the clip into the gun at 1:30.
Next focus on the Clip, add properties for clip position and rotation. The Clip pops out of the USP Glock between 0:30 and 0:40. It moves just enough to leave the players field of view. It will hover there until it is put back between 1:20 and 1:30 seconds.
Add both position and rotation properties for L_Hand_Position. The L_Hand_Position is the target for the animation IK component L_Hand, thus controls movement. The L_Hand_Position moves down and away from the USP then to the back pocket and returns with the clip. Now the clip is already there, but from the player’s perspective they have grabbed a new clip and reloaded.
Add property Top position to animate the racking of the gun. Slide the Top back at the very beginning to cock the gun and back to chamber the cartridge at the end. This is best seen in the GIF at the beginning of the article.
Finally modify the void update for the USP_Fire_Pistol script to reload the gun when the R key is pressed, as shown below. The _anim variable stores the Animator component for the USP game object, and was assigned in void Start(). If the R key is pressed the Reload parameter is triggered in the animator. Make sure the _ammo is reset to the magazine capacity.
Remember to focus on the game perspective, as this is what the player sees. This creates the illusion that the player has reloaded the gun with a new magazine.