Tips and Tricks

This page provides some ways that you can improve the look and feel of the Shooter Motion Pack. Some of these settings depend on what you want with your game and how your character is setup.

 

Spine IK

The way we allow for shooting while walking/running is that we use Unity’s layer system within Mecanim. Using this approach, we can play walking animations on one layer and shooting animations on another. We use masks to determine which part of the animations will actually play on the upper layers.

The problem with this is that the animations on the walking layer twist the spine one direction while the shooting animations on the shooting layer wants the spine in a different direction.

With Unity layers, we get a blending of these spine rotations and it mostly looks good. However, you can end up with a some rotations that are a bit off. For example, we want the gun to face forward, but instead the blending has it facing down and to the right.

In the picture above, we want the gun to point along the dotted direction (forward), but it’s not.

So, we fix this with the “Enable Look IK” option that exists on the Basic Shooter Empty and Basic Shooter Attack motions.

The way it works is that I force the spine to rotate until the gun’s direction is the same as the camera’s direction.

This works out great as it supports looking up and down too.

Twisting

Where this can fall apart is when the gun isn’t seated in the character’s hands correctly. If you remember from the Gun Core page, each character skeleton has their hands rotated differently. So, we have to setup the local position and rotation of the guns differently.

For example, Morph3D builds their skeleton differently than Mixamo… so the hand rotations are different. That means the gun placement is different.

Here’s an example of two different skeletons with two different hand bone rotations using the same gun.

Now, if we check “Enable Look IK”, we get this:

That’s because the gun is trying to shoot down the direction of the camera, but it isn’t placed correctly in the hands. So, it’s all screwed up.

So, the first thing we need to do is make sure the gun sits in our skeleton’s hands correctly. You can learn how to do that on the Gun Core page.

Jump Twisting

Sometimes, all is good until you want to do something like jump or climb when you’re not shooting.

The reason is that when you’re not shooting we just allow the full animation on the first layer (say the jump) to control the whole body. However, the rifle still wants to change the direction of the spine so the rifle is pointed down the direction of the camera.

It looks funny, but isn’t very effective.

So, we have to turn on the Look At IK for some motions on the walking layer (like Basic Walk Run Strafe), but turn it off for other motions (like Jump).

This is especially true when we don’t have an animation on the shooting layer (say we’re idle and not shooting).

To do this, we can take advantage of the new Motion Tags.

Motion Tags

Motion Tags allow us to add values to motions that we can check on later. So, we can add a tag like “Aim Spine IK” to motions like Basic Idle and Basic Walk Run Strafe.

Then, we can tell our Look IK to only activate with motions that have this tag.

With that, our jump is back to normal. However, we can still use the spine IK to look in the direction of the camera.

 

Left Arm IK

When guns are attached to the character, they are attached with the right hand. That’s what controls their resulting position and rotation. However, some guns are held with two hands. That means we rely on the animation to position the left hand correctly on the gun.

Unfortunately, you’ll quickly realize that not animations fit with all guns. For example, the Mixamo animations I use were built with a shot gun vs an M4. So, the left hand doesn’t really fit with an M4.

The real solution is to use an FK/IK solution like the Bone Controller or Final IK. Those tools will change the rotation of the upper arm, lower arm, and hand to fit as you want.

That said, I’ve added a VERY simple FK/IK solution that will rotate the lower arm. It’s not a perfect solution, but it helps. It works by adding a “Support” transform to the gun and then rotating the left arm to the support.

You can position the transform anywhere you need for the left hand to look right. However, it must be named “Support” for the system to find it.

Then, we check the ‘Enable Arm IK’ checkbox on the Basic Shooter Empty motion and the Basic Shooter Attack motion.

With that, we’ll pull the left hand bone to the “Support” transform.

Again, this won’t be perfect, but it should be better. This also uses the spine IK blending. So, it will only work when Look IK is enabled as well.