Array Index not deleting in inventory system

I am building an inventory system in unreal. Theoretically, if you right click on an object in your inventory, it spawns in front of you and is removed from your inventory. This works fine. However, when the player reopens the inventory, the item reappears and can be dropped again, effectively duplicating the item. I added a print string to test that the function removing the array element was being called, and it is being called. any idea what I’m doing wrong here? thanks.

Hi! There can be several issules:

  • check that SlotIndex is correct and is in range
  • if Inventory is struct check that you do all by reference

I’m noticing two strange things:

  1. When you spawn, you don’t use the current index. How do you know what to spawn?

  2. In refresh slot, when the quantity is > 0, surely you need to decrement it?

  1. I have a class for the item structure in the base item, that all items are connected to.
  2. I had the <=0 to check to see if the item is really in the players inventory, but it is overall unnecessary in deleting the item.

thanks. c: