Best approach for my inventory system(HELP)

I am working on a grid based inventory system. It is similar with kenshi or tarkov inventory.
I have 2 type of widgets, slot and container which holds slots.

At this point, i can pickup, wear, drop my items. But no matter how i think, i couldnt find any way to save items in my backpack. If i place an item inside it and unwear then wear it, item disappears. I cant use struct in same struct(circular) so i cant use Slot Info structure in my Slot Info. I dont know how can i do it because i want place backpack in my backpack.

And i have another question: I have checked other inventory systems. And all of them are using Unique ID’s. Item UID, Slot UID, Container UID, everything has UID. I couldnt understand why are they using that because i didnt need it until now. I am making a replicated system and it goes well for now. Will i need to make a system which uses UIDs?

the reason to Use a Unique Id system has to do with we can now hold those items somewhere else, and probably as something lighter weight. instead of keeping track of say a full Blueprint Instance with a bunch of unique functions, meshes, animations… we instead hold the UniqueID and then we can get back the exact thing.
the other reason to use a UniqueID system if not for simplifying memory at the moment we can hold the items in a different structure, like an Array<InventoryItem> then we are just playing with arrays. a UniqueID is not nessesary, but it can help for referencing because instead of referencing a full item to see what it is we can just look at the UniqueID and maybe a couple other small things because full Object Compares get expensive fast.

in your situation could I maybe suggest instead of the Slot being the item, instead the Slot holds an index of say Array<InventoryItem> and your “Backpack” just so happens to be a wrapper on that Array<InventoryItem>. now bring up 2 Backpacks is just pulling up 2 Arrays and if the Grid-Slot is an Array Index you can just MoveItemByIndex(int ItemIndex, int TargetIndex) or however you want to formulate that.

then to remove an item from being equipped you would remove from the equipped slot and put it back into the Array (if it ever left the Array that is)

1 Like

Your reply helped me much, thank you.