Cannot equip items

MartinD

New member
Hello, I have aproblem with equipping items and have no idea what may be wrong really.

I am adding an item to inventory:
C#:
Inventory inventory = characterObject.GetCachedComponent<Inventory>();
inventory.MainItemCollection.AddItem((ItemInfo)(InventorySystemManager.CreateItem(ItemDefinitionInfo), 1));

Item appears in inventory from which I select it an run (using CharacterInventoryBridge):
C#:
Item item = bridge.GetCharacterItem(inventoryItem.Item);
bridge.MoveEquip(inventoryItem, true);

As a result I get:
Code:
The Item Set for item 1 Basic Torch (3689255319) || ItemCollection Default (Main) || ItemStack(-762314086)[ 1 Basic Torch (3689255319) in ItemCollection Equippable Slots (Equipped)] could not be found and therefore the item could not be equipped. Perhaps you are missing an item Set Rule for this item?
UnityEngine.Debug:LogWarning (object)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge:Equip (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo,bool,bool,bool) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:606)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge:MoveEquip (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo,int,int,bool) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:582)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge:MoveEquip (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo,bool) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:566)
RPG.Scripts.InventoryItemButton:ButtonClicked () (at Assets/RPG_Game/Scripts/RPG.Scripts/Inventory/InventoryItemButton.cs:29)
UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

The item I am trying to add is a torch and it is part of Torches category (which is a child of Equippable). I have no idea what I may be missing here.

controller_1.pngcontroller_2.pngItemSlotSet.png
 
I'm not quite sure what's wrong either.

One thing i find odd is that you have two Category Item Set Rules. One with Equippable and one for Torches.
CategorItemSetRules are used to equip things in parallel. For example in the demo scene we use it to equip the grenad in the left or right hand, no matter what item is equipped on the other hand.

In this case my guess is that's not what you want. Do you want to dual wield a weapon and a Torch?
For that I would use a sing CategoryItemSetRule and add three rules into it. One with weapon in slot 0 (right hand), One with Torch slot 1 (left hand) and than the last one with both weapon and Torch.

If you don't want to dual wield the torch and a wapon you can have a sing CategoryItemSetRule with two rules, Once with Weapon in right hand, and another with Torch in right hand

Notice how I say Weapon, not Equippable. Weapon would be a child of Equippable just like Torch. But Torch and Weapon would not be parent/child of each other. They simply share the same parent.

The other thing I would double check is the Torch Slot ID on the Item Prefab. Make sure it matches the slot ID (the hand) in which you are trying to equip it.
If you which to equip the torch in either/both hands you'll need two prefabs one for each hand with the corresponding slot ID.
My guess is that the error happens because you have Equippable for both slots which tries to add the Torch to both hands at the same time, but it can't. So not ItemSet is created at all.

Try reading through the documentation about CategoryItemSetRules, ItemSetRules, etc... again
I hope that helps
 
I'm not quite sure what's wrong either.

One thing i find odd is that you have two Category Item Set Rules. One with Equippable and one for Torches.
CategorItemSetRules are used to equip things in parallel. For example in the demo scene we use it to equip the grenad in the left or right hand, no matter what item is equipped on the other hand.
To be hnest I do not even care. All I'd like is to have a torch in a hand and that is the only requirement for now. Also Initially I had only one rule set - default with two equippable in both hands. Did not work at all.
In this case my guess is that's not what you want. Do you want to dual wield a weapon and a Torch?
For that I would use a sing CategoryItemSetRule and add three rules into it. One with weapon in slot 0 (right hand), One with Torch slot 1 (left hand) and than the last one with both weapon and Torch.

If you don't want to dual wield the torch and a wapon you can have a sing CategoryItemSetRule with two rules, Once with Weapon in right hand, and another with Torch in right hand
Yes and that is what I have in the second ruleset but then this changes nothing in my situation.
Notice how I say Weapon, not Equippable. Weapon would be a child of Equippable just like Torch. But Torch and Weapon would not be parent/child of each other. They simply share the same parent.
And that is exactly how I have it setup. There is a category called Handheld which has Equippable as a parent and it also has two children: Weapons, Torches.
The other thing I would double check is the Torch Slot ID on the Item Prefab. Make sure it matches the slot ID (the hand) in which you are trying to equip it.
If you which to equip the torch in either/both hands you'll need two prefabs one for each hand with the corresponding slot ID.
My guess is that the error happens because you have Equippable for both slots which tries to add the Torch to both hands at the same time, but it can't. So not ItemSet is created at all.
Slot ID is 1 which exists as without inventory system using just inventory from UCC I did manage to achieve that goal of putting a torch in a hand.
Try reading through the documentation about CategoryItemSetRules, ItemSetRules, etc... again
I hope that helps
One thing that I cannot catch here:
Line 611 in InventoryItemSetManager
C#:
var itemSetList = m_CategoryItemSets[category].ItemSetList;
This is some serialisable so I assume it is set somewhere and aved in some asset. However it seems that for both categories ItemSetList is empty for some reason but I have no idea why.
 
The elements in the ItemSetList are created at runtime. The Rules define when and how the item sets are created depending on the items equipped.

To be hnest I do not even care. All I'd like is to have a torch in a hand and that is the only requirement for now. Also Initially I had only one rule set - default with two equippable in both hands. Did not work at all.
If you set a Rule with both slots with a category, it means you are trying to create an item set ONLY when you have items that can fill both slots. That means you are only able to dual wield.

You must create two ItemSetRules, on for the weapon, one for the Torch. And make sure the Torch Item Set Rule has the SlotID matching the Slot ID on the Item prefab.

Check this image from the documentation:
1646641750519.png
Notice how we have a rule for blade+shield and another for only blade.
You want a rule for only weapon and another for only torch.

If you are still struggling with this send me a mini video recording (use streamable.com) showcasing your setup it might help me explain what you need to do.
 
Right, my bad here and I suppose too much work:-( I have removed rules specific for torches and left only for Equippable. Then added two rules (for either hand empty) and now it works. Thanks!
 
Top