The Shooter Motion Pack makes heavy use of Unity’s animator layers. In this approach, the first layer (index 0) handles basic idle animations and movement. The second layer (index 1) handles the upper body… aiming, firing, and reloading.
When we’re not aiming, firing, or reloading our upper body is typically in “empty”. Basically this means we’ll allow the first layer (index 0) to control the upper body animations. Think of the second layer and the empty motion as being ignored.
However, the one thing we don’t want to ignore is having the IK bend the character’s spine even when we’re idle. It just looks better to do it. So, instead of using the standard “Empty” motion, I’ve created a “Basic Shooter Empty” motion that includes spine FK/IK support.
The properties are described by tool-tips. So, I won’t rewrite them all here. However, there are some things worth talking about.
This motion support rotating the spine and chest bones to point in the direction of the reticle.
This helps to give the character more life as the player is moving. It also helps to fix rotation errors that occur when shooting animations are put on the second layer.
Since the character can have any type of weapon equipped, the motion doesn’t really know about the weapon itself. So, the motion need to use the inventory to determine what weapon is in hand.
This motion will use the inventory and slot specified to get the current Gun Core. We’ll then use this component to fire the weapon.
While I include the Basic Inventory for free, you can use any inventory solution you want as long as it implements the IInventorySource interface.