Download

Need some expert advice on what way I should build an Inventory system, Array or Data table?

Just as the title says I am just wondering the best way for an inventory system to work. I have built an inventory system already and it just has a structure that stores the items data in an array. It seems to work great so far but then I have seen projects using data tables. What is the benefit of using a data table vs an array? any performance difference?
My other question is I have one struct that has around 40+ values and is used by every item blue print to pull data about that item, is this a really bad way of doing it? I’m wondering if this is where the data table would be better? Either way my items have a little over 40 values/attributes so what is my best option? or is there a totally better way all together. Thanks in advance for any comments and input. :slight_smile:

Thanks, I’m taking a look at that :slight_smile:

I’d say that a data table is a good way to design your items, but I don’t really see how it can be used for inventory, since a data table can’t be modified at runtime.
How are you designing the different items now? If you use inheritance, then there’s this bug to be aware of: https://answers.unrealengine.com/que…-defaults.html

Datatables are not editable at runtime.
Use the datatable to store information about each kind of item.
They are lists created ahead of time.

An array can change at runtime.
For example, you can load an array from a datatable at load.

In your case, you can creaete an array to store the data specific to the player inventory.
e.g InventoryBackpack. It can refer to rows in the datatable, or rows in an array built from the datatable.

Datatable
Mesh, Material, Power

Array
Mesh,Material,Power, Count

You’ll need several systems:
Item Display: Widget
Item Storage: Array
Ingame Item Information: Structures
Static Item Information: Data Table
Item Bonus: Object or Structure

I’m using a main parent item BP and then I made children from it for each item I have. Yes I have encountered the bug in the link you posted, thanks now I know what has been going on sometimes, lol

Thank you this cleared a lot of stuff up, I didn’t know this.