# Structure For item hold array of this structure

**URL:** <https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [March 11, 2024, 10:04pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258 "2024-03-11T22:04:07Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 11, 2024, 10:04pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/1 "2024-03-11T22:04:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [March 12, 2024, 1:21am UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/2 "2024-03-12T01:21:53Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/3/783923bcfb56aabc68ba7247b35b4cde6afa3f8d.png)

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 12, 2024, 7:57am UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/3 "2024-03-12T07:57:20Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [March 12, 2024, 9:48am UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/4 "2024-03-12T09:48:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 12, 2024, 12:11pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/5 "2024-03-12T12:11:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [March 12, 2024, 12:29pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/6 "2024-03-12T12:29:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 12, 2024, 2:18pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/7 "2024-03-12T14:18:36Z")

</div>

GUID is interesting, can u please write some examples?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [March 12, 2024, 11:50pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/8 "2024-03-12T23:50:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 13, 2024, 4:19pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/9 "2024-03-13T16:19:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [March 14, 2024, 12:33am UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/10 "2024-03-14T00:33:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 14, 2024, 3:55pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/11 "2024-03-14T15:55:55Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [March 14, 2024, 11:53pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/12 "2024-03-14T23:53:50Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 15, 2024, 12:24pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/13 "2024-03-15T12:24:06Z")

</div>

How generate GUID in ue5?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [March 15, 2024, 2:46pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/14 "2024-03-15T14:46:05Z")

</div>

> **[Guid](https://docs.unrealengine.com/5.0/en-US/BlueprintAPI/Guid/)**
>
> Guid

---

<div class="post-metadata">

**Author:** ![PlaceToPlayUA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PlaceToPlayUA](https://forums.unrealengine.com/u/PlaceToPlayUA)\
**Post date:** [March 15, 2024, 3:35pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/15 "2024-03-15T15:35:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ShadowBr0kerz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shadowbr0kerz/32/1201558_2.png) [@ShadowBr0kerz](https://forums.unrealengine.com/u/ShadowBr0kerz)\
**Post date:** [October 21, 2026, 3:49pm UTC](https://forums.unrealengine.com/t/structure-for-item-hold-array-of-this-structure/1746258/16 "2026-10-21T15:49:50Z")

</div>

structs cant nest inside themselves so the guid list workaround makes sense, but it gets messy fast once weapons need mods and ammo and backpacks need their own inventories.

thats the exact case where objects beat structs. make each item a replicated object with its own variables and repnotifies, and the nesting just works because an object can hold refs to other objects. no guid lookup tables to maintain and teh replication handles add and remove for you.

you can also try Blueprint Object Replication, a plugin for Unreal Engine that replicates nested inventory items like backpacks and weapon mods as objects with repnotifies: [https://www.fab.com/listings/e26dcf07-7c78-4e67-8e56-272cf6df8021](https://www.fab.com/listings/e26dcf07-7c78-4e67-8e56-272cf6df8021)
