Use different weapons on attack

On the BT I know you attack with the Start Stop Use Node, on the integrations demo the params are SlotId -1 and Action Id 0 as I see them on the use ability.
But how can I select different weapons on the node? I have my agent now with 4 weapons on the item folder.

EDIT: And for instance launch grenades also?
EDIT: I found Equip / Unequip Node but not sure how to use as doesn't have fields to select the weapon / slot. It doesn't get success and I got warnings: Error: Unable to find a Equip Unequip ability with category id 0
But Where can I find the category Id on my Agent ?? I don't have that field on the EquipUnequip Item Abilities.....

Last edited:


Staff member
You do want to use the Equip Unequip but the category ID isn't very easy to find without a better inspector. I'll update the integration to draw all of the available categories within a drop down list. For now the category id can be found by clicking on the item collection, going into debug mode of the unity inspector, and seeing what the id is for that category:



Staff member
This ended up being a problem with the attribute being added to the wrong field. If you update StartEquipUnequip to the following then the dropdown will appear for the category:

        [Tooltip("The category that the ability should respond to.")]
        [ItemSetCategoryDrawer] public SharedInt m_CategoryID;
        [Tooltip("The ItemSet index that should be equipped or unequipped.")]
        public SharedInt m_ItemSetIndex;
(The ItemSetCategoryDrawer was moved to m_CategoryID instead of m_ItemSetIndex)
ok, thanks, now I see the category's dropdown. On the Equip Unequip Node now I select the category and the "Item Set Index".
I select 0, 1 or 2 and I can see on the Item Set Manager Script that it changes also to Item Set 0, 1, 2....etc... (Assault, Shotgun, pistol, etc...)
But the character doesn't change the weapon, its always on the one that is at the beginning (assault). The agent has got 4 different weapons on the item hicherarchy and I have added them with the tool wizard. I don't see any warnings or errors.
Am I missing anything else to change the weapons?
Hi Justin,

Can you please double check out that the Start Equip Unequip on the Behaviour Design Node is working?
It's not working for me and I was wondering if there was another typo / bug as the one above related to category Id .

Under the category Weapons, If I try to change the ItemSet 0, 1 and 2 (I have correctly set up the ItemSet0, 1 and 2 on the Item Set Manager) it doesn't change at all (Its always on ItemSet 0 from the start, and marked as active)


NOTE: I've tried on my script with the code m_EquipUnequip.StartEquipUnequip(WeaponItemSet); and works fine so must be something related to using on the Start Equip Unequip node in BD.

If not... where is the best place to add the node on the tree (I'm placing it just before Aim and Use)
Last edited:


Staff member
As a test I added just the Start Equip Unequip task to the demo behavior tree and had the agent switch from the assault rifle to the sword. The agent successfully switched with the code modifications above.

A good place to debug this is to place a breakpoint within StartEquipUnequip.OnUpdate and see where the code returns early. The EquipUnequip ability should start and change the weapons.
Perhaps I've misunderstood what this task is meant to do, and after some playing around I've realized I definitely misunderstood the "Disabled Index" in the Item Set Manager. My AI agent has two weapon sets, each with its Disabled Index set to -1. I thought that this meant that assigning a value of -1 in the task's Item Set Index would select the disabled Item Set and I could toggle back and forth. I now see that I must set the task's Item Set Index to either 0 or 1 (or presumably I could create a variable set it elsewhere to either 0 or 1).

My remaining questions then, are 1) isn't this supposed to toggle, or is it designed such that to have my AI agent unequip all weapons one must enter a number that doesn't match any item set? and 2) In the Item Set Manager, what is the function of the Disabled Index?



Staff member
This is a long doc but I recommend going through this page for a background on how Item Sets work: Let me know if you still have any questions on the Disabled Index after going though this doc and I'll update the doc with that information.

Setting an Item Set value to -1 should completely unequip the Item Set and as a test I tried that with the demo scene and the agent correctly unequipped all items.


Staff member
I set it as the very first node just to test it. I would start there as well just to get it working and then you can determine where you want to do the equip/unequip within your tree.