Best practices for inventories and items using Data Assets and Objects or Structs

Hey everyone! Hope all is well.

I wanted to reach out to see if anyone is familiar with what I’m considering for my project. Recently, I’ve been planning to create an inventory system, and through most of my research, I found that the best solution for me would be to use Data Assets along with either Structs or UObjects.

For my game, I’m planning to have several item types and classes, including, but not limited to, base items, consumables, weapons, equipment, etc.

My question is: When it comes to saving data that changes during runtime such as ammo, attachments, durability, or quantity what do you think is the better approach: UObjects or Structs?

I’ve considered using Structs, but I’m concerned that having all the information (such as weapon details) in a Struct might be wasteful since I will have different types of items with unique data for themselves, especially since a consumable wouldn’t need this data, and a weapon class wouldn’t need the consumable details.

So, am I missing something here? Is it possible to use inheritance with UStructs? For example, could I create a base struct like FItemBase, and then derive other structs from it, such as FWeaponBase, which I could use in my inventory component’s array of item variables?

Alternatively, should I just use UObjects to store and manage this data?

Thanks in advance for your help!

Since Structs are used to keep the same data and it doesnt change other then yes no for boolean and numbers change +1 -1, you can save the data pretty easy if you run with structs. if you need objects to save that are bps then i would recommend using guid’s the work pretty good.
In short I would recommend structs only because they tend to be easy to grab when you need em

I see, thanks for your reply! I was also thinking about using Structs, but do you think its possible to use it with several types of items? Weapons might need to store data for things like ammo, attachments etc. While other items will not need such data, so it seems inefficient to have one struct that has all the properties for all items. But like I had said in the original post, from what i’ve read It seems inheritance might not be possible, but Im not sure is that something you’re familiar with maybe structs do support inheritance?

Yes, structs support inheritance, as long as they are defined as USTRUCTs. You can also use nested structs.

However, if you are creating a complex inventory system and are worried about redundant data, then I would look into using a database like SQLite.

Data tables work for simple inventories, but don’t very well with many-to-many relationships.

Thanks! I’ll look into the nested structs and the inherited structs, I thought the same for the inventory system, I wasn’t really planning to use data tables but the primary data asset type to have the static data, then save the list of structs in someway. Probably using SQL. Thanks again :).