Inventory structure - names map based with DataTable and multiuse items, item condition, unique item – how to?

Hello

I’m working on game inventory. I have no problems with add items, functions, widgets etc but with inventory correct structure and best workflow.

I would like to use maps (name|integer) based intventory with item info in DataTable, this is elegant, lightweight, easy and fast working solution, but I don’t know how to handle two kinds of items in this system:

  • items with changed condition, wear in %
  • items with multiple use, like a ammo magaizne - one item can have 30 bullets for example - in inventory I need different magazines. One will have 30 bullets, another one 15, if empty removed ofc. When magazine will be drop to world, it still should have info about bullets count. Of course items with changed condition and uses will be not stockable.

Data tables are read only and map name|integer store only item ID and count. So, I can add to map item ID and stack, but no condition and uses (e.q. bullets).

Now I have some “system” based not on maps but item own structure and it works for my needs, but is over complicated (now here not so much items, so ok) and hard to update structure in future. Also when over 100 items it works too slow imo, inventory loads over 1s - with map based inventory, any count loads instantly.

I watched many tutorials about Skyrim, Fallout like and other advanced inventory, but they always omits the point about item condition and uses (if more than 1). Of course I also looked over the web and here.

Maybe I just missed something, so link to right tutorial or website, thread will be more than enough. Tag is Blueprint only, but if here is only C++ solution - welcome.

Thank you!

Inventory system - how to handle decaying items - Unreal Engine / Programming & Scripting - Unreal Engine Forums

A thread I made for same problem not long ago.

I am making any inventory items derive from a Uobject class that holds the basic data common to all items.

Items that need decay derive from a child class of that Uobject which also implements whatever functionality you need for decay/condition.

Any data that doesn’t change you can hold in a data table. The stuff that might change at runtime (condition) you can keep in a struct. But you just save the whole Uobject so it’s still easy to manage.

2 Likes

Yes, but you found how to save Uobject with save game?

you’ll need to store a reference to the objects somewhere.

For instance, the players inventory could be an Array of these uobjects, and then you just save that array like any other variable during your save/load game process.

In my project, I use an actor component to manage the players inventory. It has some blueprint code to handle transferring items, and it has an array of uobjects that represents the current inventory.

I am using Easy Multi Save plugin which makes saving pretty simple - I just flag the array for save game and it gets handled automatically.

But with normal, manual save/load process, all you have to do is get the array and set it within the save game object before saving, so it’s still pretty straightforward.

1 Like

I use actor component too, but uobject is not saved or I do something wrong. On save it save, but can’t load.

On load it load map Values but keys are empty.

I not have any payable plugins for save, but I think it should be possible with clean ue5?

i would expect so, but that is a more specific question. It may be worth making a new thread if you can’t troubleshoot it yourself.

Might test to see if it’s just specific to the map itself, or the uobject. I.e. if you try to save/load a map in some actor, does it work? If so, then there must be something about using the uobject, otherwise it’s just something about saving/loading maps.

It’s not something i’ve dealt with before so that’s the most I can offer unfortunately.

1 Like

I saved maps before and it works. Maybe not maps with objects :wink: I will try save struct or so, it was my idea now too, but thanks for help.

Thank you for your help. Problem was on add to inventory stage, it shows nice in game, but later it loaded default object class with no vars changed. My fault.

Now it save/load with uobject in struct or map (I use map) and inside uobject many vars, like a weight, texture, mesh etc, tons of - all works well - save/load

1 Like