# Struct recursion via Arrays - unsupported, but why?

**URL:** <https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035>\
**Category:** Blueprint\
**Tags:** tarray, Structure, unreal-engine, CPP, Blueprint, question\
**Created:** [September 10, 2016, 9:11pm UTC](https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035 "2016-09-10T21:11:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gryzly123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gryzly123](https://forums.unrealengine.com/u/gryzly123)\
**Post date:** [September 10, 2016, 9:11pm UTC](https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035/1 "2016-09-10T21:11:52Z")

</div>

You can’t create an instance of a structure inside that very structure, it’s completely understandable, as such action would fill the entire memory recursively upon object creation.

However you also can’t create an array of a structure inside itself, even though the aforementioned problem doesn’t exist - upon adding an element to that array, a new empty array would be spawned inside the child object and that would be it.

Since that option is not available in Blueprints’ Structure creator, I tried to create the struct with C++:

```
USTRUCT()
struct FCorridorData
{
	GENERATED_BODY()

	UPROPERTY()
	uint8 Length = 0;

	UPROPERTY()
	TArray<FCorridorData> ChildCorridors;
};

```

However the compiler will throw an error:

```
Struct recursion via arrays is unsupported for properties.

```

But why? Having an ability to create child structures in property editor would enable nesting, useful in creation a lot of stuff, i.e. mazes or vent systems as tools for artists.

---

<div class="post-metadata">

**Author:** ![xxAtrain223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xxAtrain223](https://forums.unrealengine.com/u/xxAtrain223)\
**Post date:** [November 16, 2016, 8:11pm UTC](https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035/2 "2016-11-16T20:11:41Z")

</div>

Still not available in 4.14.

---

<div class="post-metadata">

**Author:** ![Hyperloop](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hyperloop/32/1203427_2.png) [@Hyperloop](https://forums.unrealengine.com/u/Hyperloop)\
**Post date:** [December 26, 2016, 5:38pm UTC](https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035/3 "2016-12-26T17:38:07Z")

</div>

This would also be recursive, as the child struct would itself contain an array and so on. My suggestion is to define your child struct separately and then include it in the FCorridorData struct.

---

<div class="post-metadata">

**Author:** ![gryzly123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gryzly123](https://forums.unrealengine.com/u/gryzly123)\
**Post date:** [December 28, 2016, 11:03pm UTC](https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035/4 "2016-12-28T23:03:03Z")

</div>

The child struct would contain an array and this is exactly what I want. It won’t go to infinity (as in until it eats all the memory) because the array is **empty by default** - the chain **ends** unless you explicitly tell it to go one level deeper.

---

<div class="post-metadata">

**Author:** ![SeregaDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SeregaDev](https://forums.unrealengine.com/u/SeregaDev)\
**Post date:** [March 19, 2024, 3:00pm UTC](https://forums.unrealengine.com/t/struct-recursion-via-arrays-unsupported-but-why/370035/5 "2024-03-19T15:00:25Z")

</div>

check this

```auto
class A
{
public:
	int32 AData;
	TArray<A> Children;
};

```

works well w/o reflection. But I can’t use replication for such data structures which is not convenient. Only RPC calls  
or use another replicated array with data and in the tree save only indexes in this array
