What is the best way to implement this kind of inventory?

Basically a DayZ style inventory, I’m struggling to figure out what is the best way to organize such inventory, where the item can contain another item with items and etc. All of them will contain per Item data like their condition. Maybe somebody already has made something like this, or have some ideas how to implement this? I was planning to create an actor component and use it, but I won’t be able to use it with items, because they are not objects, but a set of data about them.

Also, I thought that Inheriting from Object may help, but blueprints array can only store references or classes, I’m not strictly bundled to BPs but I just want to leave c++ as a fallback solution, in case this can not be done in blueprints.

Each item could just have an Array of item objects or item data structs which can then be used to set UMG images, text, etc and spawn item Actors. each entry in the array is an onject whose parent class is the same type of object as has the array so you can nest them like you were saying.

I think that could work. I dont know if structs can have arrays but objects sure can.

Thanks, I’ve just implemented something like this, but there is another problem: UObject must have a parent object, and it looks like it does not actually get destroyed without destroying daughter object, and there is no way to change the object’s owner.

change child’s owner before destroying. Something has to catch it or it will be garbage collected and vesides you lost the reference.

If container object is destroyed and you want to preserve the objects inside, You can always move them tothe container’s container, but you still have to decide what happens when the container is the top level of the hierarchy, then what? do they spawn into the world and spill out? IE spawn actors using their data rather than stuffing them into some basic inventory layer? Basic inventory level sounds better.

Hiw you answer that question will determine whether you need to use recursion to move all the objects.

How to change object’s owner?

What do you mean its owner. Do you mean the Owning Actor or the container item that it’s "inside’ of?

“change child’s owner before destroying. Something has to catch it or it will be garbage collected and besides, you lost the reference.”
Child’s (uobject) owner, it looks, like there is no API to change its owner.
All our items and containers blueprints inherit UObject.

Good. They should all act the same. All you have to do is check if the child has a parent co tainer item. In fact this way you dont even need arrays. Just every child object has one parent co tainer object variable which can be either another item or nothing. If it is nothing then it is not inside another item but should be spawned into the world or destroyed.

The top container can be the player themself or perhaps some kind of Inventory objectTHe tricky part is that maybe we do need arrays of child references too because otherwise how do we dig deeper and find the next layer down?