Question about equipping and unequipping items

Finnt

New member
Hello, I have a question about equipping and unquipping items on a character. I used these resources to try and get it to work, but I was not able to get all the information that I need.
Video from Opsive Youtube Tutorial Series about the Inventory System:
Documentation: https://opsive.com/support/documentation/ultimate-inventory-system/item-objects/equipping-items/

I think I followed the instructions in these sources and checked multiple times if I was missing something, but maybe I have been overlooking something. My setup is clearly not done yet, as I think it is missing the input to equip/uneqip. I thought maybe I need an ItemAction for this, but I dont think there is one and I don't think it was mentioned in either source, that it was necessary. Or is it and I should try to code my own InputAction for that purpose?

So far I am able to add ItemPickUps from the scene to an inventory and I was also able to write a new version of the DropItem ItemAction for my game, where the item then is fed to a creature in the scene and a small tweening animation is played. However I do not want to use that anymore and instead equip/unequip the item.

I think overall the Ultimate Inventory System might be too complex for my skill level and my needs for the project and maybe I should try and code a simple inventory system on my own, but I have committed some time to try and get this system to work, so I thought I will ask here before trying something new on my own.

Thank you for any help!



On my character I have these components:

1715022962807.png1715023016864.png

1715023109326.png

On my Inventory UI I have these components:
1715023233570.png1715023254508.png
And these other components: (only 5 screenshots are attachable)
- Item View Drop Handler
- Item View Slot Drag Handler
- Item View Slot Move Cursor
 
Hey there!

So to equip an items all you need to do is move them to the "Equipped" ItemCollection.
As mentioned in the video tutorial at the beginning, The Equipper component monitors items beind added/removed from the "Equipped" ItemCollection and visually equips/unequips items accordingly.

So in most cases we equip/unequip items from the InventoryGrid. This is done with an ItemAction "MoveToCollectionItemAction".

If you check the InventoryGrid in the demo scene you'll see it has this component:
1715070238900.png

If you check the Equipable Item Action you'll see this:
1715070281305.png

You'll learn how to setup your ItemActions in this video tutorial (using UIDesginer window makes this quite easy):


Now, imagine you don't want to equip from the UI with an ItemAction. But instead you want to do it through your own code, by pressing a button or wathever. Then all you need to do is add the item to the "Equipped" ItemCollection. (Remember the Equipper component always monitors the "Equipped" item collection so you don't need to call any functions on it, it'll visually Equip/Unequip items automatically on it's own)
You'll find some code examples
here: https://opsive.com/support/documentation/ultimate-inventory-system/inventory/
and here: https://opsive.com/support/documentation/ultimate-inventory-system/inventory/item-collections/
specifically for ItemSlotCollection here: https://opsive.com/support/document...entory/item-collections/item-slot-collection/

If you need any pointers don't hesiate to ask :)
 
Hello, thank you for your fast response. The MoveToCollectionItemAction was just what I was looking for. I did not understand, that this was the ItemAction that was necessary for equipping items, but it does make alot of sense.

I have not tried yet using UIDesigner to setup the ItemActions, but will try to do this as soon as possible.

I ran into another problem, that keeps me from trying to solve my original problem. Now, Items from ItemPickUps are not added to the inventory anymore. The Pickup disappears, but the inventory stays empty. What is mysterious is, that this worked fine until yesterday. I tried reverting all my changes, but this did not help. So I don't think it is actually related to the changes I made to complete the equip setup. I also don't think, that this is related to the ItemPickUps or the Interaction, because I definetly did not do anything on those objects. Maybe the cause could come from me applying all the Inventory components on my character to the prefab and something went wrong there. But I have really no clue. Can you help me resolve this problem as well?

Thank you for your help!


Edit: I realised, that I can just add items to the inventory item collection in the editor. This made it possible to test the Item Action Menu UI. So equipping and unequipping does work now. Thank you again, your comment was very helpful!

The other problem, that I am unable to add Items to the Inventory from ItemPickUps remains though and I have still not figured out what changed since yesterday.
 
Last edited:
The other problem, that I am unable to add Items to the Inventory from ItemPickUps remains though and I have still not figured out what changed since yesterday.


My guess is that they aren't properlys setup so perhaps they have no items, that's why picking them up doesn't do anything.
Either that, or you've added some kind of ItemRestrictionObject on your Inventory that prevents the item you are trying to pickup to be added to the Inventory.

Please send me some screenshot of the inspector of your item pickups, your Inventory and anything else you think might be relevant.
Perhaps you can also make a short video to show exactly what happens when you try to pickup the item
 
I am sorry for my late response. I only got around to working on the project some more and was able to find the cause of the problem. My mistake was not looking at the ItemPickUps, because I thought, they can not be the problem, as I have not changed them.

But they were: In the ItemPickUp Script, the "AddToItemCollection" had it's purpose set to Main, but the name was not set. My guess is, that this still worked before, because I only had one ItemCollection before. But now that there are two, the name was required. The solution was to also put "Main" as the name string.

Thank you very much for your help!
 
That's not normal. I would recommend you double check your two ItemCollections.
Make sure one of them is set as purpose Main. You will need a main itemCollection otherwise you will have issues in other parts for the system too.

My guess is that you second itemCollection is considered as the main collection.

The main Itemcollection should always be the first in the list of ItemCollections and with purpose Main
 
I think it is set up like you describe. The first ItemCollection in the list has the name and purpose Main.

1715596870645.png
 
Last edited:
Top