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
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!
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
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