Structure For item hold array of this structure

Guys and girls. My inventory builded on structures
item is Structure BasicItem

inventory is array Structure BasicItem

everything ok i can migrate items between different inventories containers etc. BUT!
Some items must have in them inventory too (like backpack, some cases and other stuff) and can be added to another inventories

how can i add variable Array of Structure in same Structure type

Hey @PlaceToPlayUA!

You cannot add a struct to itself. However you can add another kind of struct to a struct!
Maybe you could create a struct for containers like backpacks and boxes?
In blueprint at runtime, that should work. Maybe use a “SecondaryInventoryStruct”?

Outside of runtime, just open the struct blueprint and add it to the struct itself! :slight_smile:

But how after use backpack like item? I mean i have structure array for items, and backpack can be there and items can be in bacpack)

if you want it infinitely deep, ie items within items within items

use an object instead of a struct, however this does complicate other things like multiplayer and saving/loading

Ibefore it was on objects, but i couldn’t make replications for them(

it can be done in c++ but yeah a pain.
Depending how many items you plan on having you could go up to an actor component or even actor for replication. likely not a problem for indy level games.

otherwise to do it with structs what i do is give them all a GUID have them all in some sort of item manager and then just have them reference their parent/child item GUIDs in the item struct

GUID is interesting, can u please write some examples?

think of it just like a reference. so you have a list of all items in an array.

each item struct has an inventory which is an array of GUIDs those point to another item struct that can have an inventory array of GUIDs without having a circular dependancy.

something like this i think before, will be good to know how to generate GUID, now using custom ID.

but now this problem is not a problem)) there is bigger (

try to explain)

inventory have items, all of them have basic structure with sub structure from sub DT

but different items must have different structures:
weapon must have slots for mods on it, magazine with bullets and others stuff, and different weapon must have different mods etc.
armor - have different pockets for magazines
helmet - different mods like night vision and other

and some “containers” like backpack, some other cases

so question is how do this correctly? if on actor it’s not a problem, but in inventory it must be all in one but they different

if using structs then yeah you probably need to include all information at all times. just use an enum or something to identify the type and your functions can edit it.

a lot of that can be modular though, you can have an array of mods and in that determine what mods can be used, ie one for ammo, one for weapon mods, one for helmet mods etc

but how to add array of items (mods) if structure couldn’t have self type in self structure

i mean mods and other stuff is item structure, and weapon item too)

as i said you’re not adding the structure, your adding the GUID to the structure.

then you’ll have an array of all items and you’ll find that item by GUID

so basically your structure contains your item GUID, item data and 2 GUID arrays, one for mods and one for inventory (ie backpack)

How generate GUID in ue5?

thanks friend) i try to do something and leave feedback later)