Fixing Weapons for the other states

We need to set our game up so that our character does the correct aiming animations when we select our weapon. Currently, it only does the pistol aim for the grenade and the assault rifle. To do this, we need to first change the firing of the blend tree.

Originally, we had a pistol aim for our aiming layer. We need to change this into a blend tree so we can swap the states in which we hold a weapon. Instead of simply aiming the pistol in the center, down, or up and altering the animations, we now need to change those to blend trees so we can add in the pistol, rifle, and grenade idle.

Inside each blend tree is a set of animations. For our rifle, we will need to create an aim up or aim down as well as a standing still rifle aim. For the grenade, let’s just keep that at fighting idle since we will need to use a throw animation.

We will use the idle setting as the parameter so when we are 0, we use pistol down, with rifle, we use 1, and with grenade, we use 2.

With that done, we can sort through the different idles and properly hold the correct animation. We also need to button some things up.

We need to make sure that we can only fire if we are aiming.

For our equip gun and our change idle state, we want to make sure we can only change those options if we are not aiming. Otherwise, we will swap weapons and won’t be able to transition animation states.

In our aiming state, I want to make sure that if we decide to use a grenade, this sync layer tied to the aim will override the base layer. This is a simple check where if we are in _currentIdleState 2, we will play the anim trigger.

We also want to make sure that if we are in the grenade state, we don’t do a camera shake. Otherwise, it would look ridiculous.

With these minor adjustments, we now have a beautiful system that can help you swap weapons.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ