What's the best inventory system/framework? Best practices?

Hi, so how do you make a robust inventory system, taking into consideration saving?

  • Assuming you’re using an array for the inventory, where do you put it, and what type is it?
  • How, and where, do you store default item properties (texture, class etc.)?
  • Do you have any hard references that go into the save game object?
  • If you don’t save any hard references, where, when, and how do you load the referenced assets (like textures etc.)?

Thanks.

Generally, it seems best to put the inventory array into a component class which is added to the character or its controller. As for type, most people use a structure with members like ItemName and Quantity ( so you can do things like stack potions, arrows, or coins to one bag slot).

To setup item properties, data tables are usually used for this. Or an external database if you use an SQLite plugin or something. The inventory slot structure would just point at a row name (or row number with a normal database).

Done like this, you won’t really need hard refs in save, since you can just store the inventory array which is just made of names and ints.

And without refs, you just need the character or whatever to look up the item in the data table to set any meshes/textures/etc.. on begin play to change how they look.

1 Like

But when accessing that data table, does it load all the assets it references?

Like, imagine having 1000 items each with a texture icon of 10 Mb.