Removing Item from Inventory

Hey there!

I’ve been following this series of tutorials from Unreal Engine. And I wanted to delete items from array, ignoring the “drop item” part, just remove an element from the Inventory array when used. The thing is that I’ve been trying to recreate something like that but it doesn’t work.

Inventory is a Struct array which contains all the data from each item on the inventory. Making an array from the Item Inventory Struct, returns the full list of actors inside the inventory, so finding the index from the actor I want to remove should do the trick. But it doesn’t.

Do you know anything that could help me?

Thank you,

Neptuno

You need to start from basics such as these

Hey,

Thank you for the reply. I’ve just seen the video you sent me, and I think I understand it, but I did the same thing as he did in the video.

He mentioned about not removing an index during a For Each Loop, and that’s what I’m doing. I tried to do what he said, but it didn’t work. Removing elements from an array isn’t safe during a loop?

Thank you and sorry for the inconvenience,

Neptuno

It might help you to understand

Hey!
Finally, I found a solution. I created a new “Scan for Item” function on the HUD widget. This function looks like this:

And basically looks for the given item on the inventory, and checks if it’s inside, if so, I can get the Slot info and later I can remove that index from the array.

1 Like