Creating Equippable Weapons
Last updated
Last updated
Note: It is recommended you have your AI fully set up before proceeding. If you haven't yet done this, you can see the Getting Started section for a detailed tutorial on creating an AI.
Emerald AI features a built-in system that allows an AI to equip and unequip 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.
First, you will need to go to go to your AI's Animation Profile and assign an Equip and Unequip Animation.
The Equip and Unequip Animations can be found under the Equip & Unequip Animations foldout of your AI's Animation Profile.
Next, you need to Open the Animation Viewer. This can be found within your AI's Animation Component right above the Edit Animation Profile button that was just pressed. The Animation Viewer allows you to view animations right within your scene and allows you to create Animation Events from a list of presets.
Once you you do this, you should see your AI previewing its animations.
Find your AI's Equip animation using the Current Animation pulldown then set the Event Type to Equip Weapon. Using the timeline area, find the frame you would like the weapon equipped and then press the Add Event button with the + icon. This will automatically add the Animation Event, along with all needed parameters.
Important: Choose the Equip Weapon event for the weapon type your AI is using. If your AI is using both weapon types, you will need to do this for both the Weapon Type 1 and Weapon Type 2 equip animations.
When you are done, press the Apply Changes at the bottom of the Animation Viewer to save your changes.
Important: You now need to do the same process, but for the AI's Unequip animation.
Find your AI's Unequip animation using the Current Animation pulldown then set the Event Type to Unequip Weapon. Using the timeline area, find the frame you would like the weapon unequipped and then press the Add Event button with the + icon. This will automatically add the Animation Event, along with all needed parameters.
Important: Choose the Equip Weapon event for the weapon type your AI is using. If your AI is using both weapon types, you will need to do this for both the Weapon Type 1 and Weapon Type 2 equip animations.
When you are done, press the Apply Changes at the bottom of the Animation Viewer to save your changes.
The last step is setting up the Items Component with your AI. If you have not already added an Items Component to your AI, please see the Applying the Items Component section.
With your AI selected, open the Weapon Settings foldout and create a new element by pressing the + button. Your AI needs to have two weapon objects; a holstered weapon (typically attached to the back or hip) and a held weapon (typically attached to the hand). The Holstered weapon will be the visible weapon when the weapon is not equipped and the Held weapon will be the visible weapon when the weapon is equipped.
You then add these weapon objects to the AI's Items Component. The Held object goes in the Held slot and the Holstered object goes in the Holstered slot.
Important: You will want to disable your held object so it is not visible. This will be enabled through the event we created when the AI is equipping their weapon.
When you are done, test out your AI to ensure everything works correctly. The AI should take equip their weapon when entering combat and put it away when they exit it. You can see the included Equippable Weapon Demo for a working example, if needed.