Item components

Sayu

New member
Hi! I need a help with items, first I create an item with ucc then I use the integration for the uis, it works fine and it adds to inventory during runtime but when I try to equip it, the item spawn with it's item, third person person perspective and shootable weapon components deactivated then it gives me a few errors on console about those components
 

Attachments

  • Capture2.PNG
    Capture2.PNG
    83.7 KB · Views: 1
  • Capture.PNG
    Capture.PNG
    33.2 KB · Views: 1
These error happen when the item is spawned but can't find the player gameobject.

Can you show me your InventoryItemSetManager with the ItemSetRules? My guess is that your Rules don't match your Item Slot ID on the Item Prefab. Make sure you add a rule to equip your pistol in the correct slot.

Are you trying to make a pistol that is equipped in the right, left or both hands?

Does your Character have the ItemSlot components with the correct ID to know where the item should be spawned?
 
it's supposed to be a two handed pistol, the character does have the item slot component where the items should be spawned
Also that error started appearing in the console, don't know if it has anything to do with it
 

Attachments

  • Capture3.PNG
    Capture3.PNG
    25.6 KB · Views: 2
  • Capture4.PNG
    Capture4.PNG
    64.2 KB · Views: 2
Probably the issue is that you've set the pistol to be two handed, but your character only has one slot. So it doesn't know what to do with the second pistol instance.

I'd recommend you add a second ItemSlot to your character with slot ID 1, that should allow your pistol to be spawned (even if you're not using it yet).

As for the error in the console I'm not sure what it is about. The error message is cut, could you send me the full message? That might help me understand it a bit more
 
So nothing happened after I added the second item slot, also the error appears when I try to select a item collection in inventory and now it doesn't display any of them Capture.PNG
 
Well that's a very weird error. It's comparing the name of itemDefinitions and for whatever reason it can't seem to sort them. It's the first time I see it. Looking at the code I have two guesses as to how it could have happened.

Try to change the ItemDefinitionEditorUtility class function SortOptions:
Code:
/// <summary>
/// Returns a list of options for sorting.
/// </summary>
/// <returns>The list of sort options.</returns>
public static IList<SortOption> SortOptions()
{
    return new SortOption[]
    {
        new SortOption("A-Z", list => (list as List<ItemDefinition>).Sort(
            (x, y) =>
            {
                if (x == y) { return 0; }
                if (x == null) { return -1;}
                if (y == null) { return 1; }
                return x?.name.CompareTo(y?.name ?? "") ?? -1;
            })),
        new SortOption("Z-A", list => (list as List<ItemDefinition>).Sort(
            (x, y) =>
            {
                if (x == y) { return 0; }
                if (x == null) { return -1;}
                if (y == null) { return 1; }
                return y?.name.CompareTo(x?.name ?? "") ?? 1;
            })),
        new SortOption("Category A-Z",list => (list as List<ItemDefinition>).Sort(
            (x, y) =>
            {
                if (x?.Category == y?.Category) { return 0; }
                if (x?.Category == DatabaseValidator.UncategorizedItemCategory) { return -1; }
                if (y?.Category == DatabaseValidator.UncategorizedItemCategory) { return 1; }
                return x?.Category.name.CompareTo(y?.Category.name ?? "") ?? -1;
            })),
        new SortOption("Category Z-A",list => (list as List<ItemDefinition>).Sort(
            (x, y) =>
            {
                if (x?.Category == y?.Category) { return 0; }
                if (x?.Category == DatabaseValidator.UncategorizedItemCategory) { return -1; }
                if (y?.Category == DatabaseValidator.UncategorizedItemCategory) { return 1; }
                return y?.Category.name.CompareTo(x?.Category.name ?? "") ?? 1;
            })),
    };
}

Do let me know if that fixes the issue
 
Top