Stacking/Sorting Inventory Items

Hi,

You could try to use a Struct for your items. The Struct will containt your Item class and the number of time the Item is present. Something like that.

So instead of having an Array of Item, you’ll find yourself with an Array of Struct.
If an item is only present once in your inventory, you’ll have a Struct with an occurence of 1. And if it’s present 20 times, you’ll can regroup them in one struct with an Occurence of 20.

This system could also allow you to easily split your eventory and for exemple, split a Struct that contains 20 items into two structs that contains 10 items.

Hope it’ll help !

1 Like