Setting up an Equippable and Unequippable Weapon - Black-Horizon-Studios/Emerald-AI GitHub Wiki

Setting up an Equippable and Unequippable Weapon

Emerald AI features a built-in system that allows an AI to have sheath-able weapons through Animation Events and the game objects attached to their bones. This makes it possible for an AI to have more believable non-combat animation and to show an AI pulling out and putting away their weapons.

Note: Version 3.0 of Emerald AI is required to use this feature.

Step 1

First, you will need to go to the Animation>Combat tab and enable Use Equip Animations.

Once you have enabled the Use Equip Animation, two additional animation slots will become available. Apply your Equip animation (Pulling the weapon out) to the Equip animation slot and the Unequip animation (Putting the weapon away) to the Unequip animation slot.

Step 2

Go to the AI's Settings>Items to assign your Sheathed or Holstered Weapon and your Held Hand Weapon.

Your Sheathed or Holstered Weapon should be enabled and parented somewhere on your AI's bone transforms such as their back or side. Ensure that you assign this to the Holstered or Sheathed Weapon Object slot as shown above.

Note: This game object should be enabled.

The Held Weapon Object should be attached to your AI's hand bone transform so that the weapon object follows an AI's animation. This is the object that the AI will use its combat weapon. Note: Every model is different so it is important that the weapon object is placed on the hand bone transform or it will not properly follow an AI's animations. Ensure that you assign this to the Held Weapon Object slot as shown above.

Note: This gameobject should also be disabled as Emerald AI will enable it when it's equipped.

Step 3

Now, you need to create an animation event that will trigger the enabling or disabling of the specified weapon.

To do this, go your AI's Equip Animation object. Find the frame that the AI should equip their weapon and press the Create Animation Event button. This will create the Animation Event, but you will still need to assign a function name and pass a parameter. For the Function, use EquipWeapon and for the String parameter, use Ranged or Melee (depending on what weapon your AI should be equipping).

This process is similar to the equip animation, but with your AI's Unequip animation and a different function name. Go your AI's Unequip Animation object. Find the frame that the AI should unequip their weapon and press the Create Animation Event button. This will create the Animation Event, but you will still need to assign a function name and pass a parameter. For the Function, use UnequipWeapon and for the String parameter, use Ranged or Melee (depending on what weapon your AI should be unequipping).

Note: The unequip function name should be UnequipWeapon and not EquipWeapon.

Step 4

Next, you will need to assign an equip and unequip sound for your AI. These will both play automatically when the EquipWeapon and UnequipWeapon Animation Events are called. If you are not using Both Weapon Types, the equippable weapons setup is complete.

Step 5 (Both Weapon Types Only)

If your AI uses both weapon types (both ranged and melee), the process is the same as the guide above, but you would just do these steps for both your ranged and melee attack animations.