Blueprint Array related bugs (pin type detection error, get as reference, in struct array related)

Related thread:

Hi all,

I tried to set values to an array in struct through a local reference(?) of the array.
“Break Array” seems to return a ref of array, but only values in local one are changed.
I guess “Set” function does not set a ref but makes a copy of array.

It maybe better to separate the thread but I found another bug while testing array and structure related nodes.

“Make Array” cannot detect pin types if
1.Wildcard pin (like “Array length” input pin) is connected to “Make Array” output pin first
2.Then connect integer pin (like “Make LiteralInt” output pin) to “Make Array” input pin

This can be recovered easily but… want to be fixed.
1.Remove all links from Make Array node
2.Connect input pin first.


Engine version: 4.15.1

1.png: Test1_MakeArray
This doesn’t compile.
Make array cannot detect pin types if wildcard array pin is connected first.

2.png: Test2_Resize_GotArray
Get array seems to return a copy of array, (not a ref)

3.png: Test3_Resize_MadeArray
Cannot resize an array made with Make Array.

3-2.png: Test3_2_Resize_LocalValueArray
Works correctly.

4.png: Test4_Resize_InStructtArray
Resize Arr_1

4-2.png: Test4_2_Resize_InStructtArray
Resize in struct array.

5.png: Test5_SetArrayElem_to_Array_in_Struct
Works correctly.
Set Array Elem to the array which Break Array returned.

5-2.png: Test5_2_SetArrayElem_to_Array_in_Struct
Through temporal array.
Set may be the cause.

st_test_intarray.png: Definition of struct used in tests.

log.png: Outputs.

I’ve run into this problem a few times, as well.

Seriously hoping that it will get a fix one day.

This is intended behaviour. If you want to modify an array within another BP or in a function (via parameter), you should make the Array be a array of UClass instad of USTRUCT.
Structs are always Copy-by-Value and thus you never edit the “real” struct but a copy of it when passed as a parameter.
However a UClass Array does what you want.

How do you instantiate a UClass without a transform?

Derive from Object and not Actor.

So, what is “fixed” with UE-24080 mentioned in the thread I wrote as Related thread?

Improve Get Array Item to return by-ref instead of by-value

Well the thing is as someone mentioned above, is that Structs(USTRUCT) as far as the entire engine is concerned is almost-never passed around as a Reference, and rather is just passed by Value(Copys).
This will work the way you want it to work if instead of Structs(USTRUCT), you change your data type to be a Class(UCLASS), because the engine always passes UClass’s as pointers/reference.

If you dont want to switch to UClass then the only other way to edit a Struct that you’ve added to an Array and have it be the one that resides in the Array, is to change it in C++ without the engines help(A.k.A without blueprints).

Nah, you don’t need C++ for this. Here’s one of the ways to do it in BPs:


Maybe Break struct (not ForEachLoop),
and set Array Elem is not needed for this, I think.
(As passing an array as ref, values in original array can be changed in Set members in CommonUniData.)
Or you meant array elements are structs? (If so, maybe affected by UE-6451.)

Set Members in Struct node doesn’t work if the Struct is contained within an Array

(Target Fix: 4.16)

By the way, can we store a ref of array as a local variable?

You can break the struct put it back together, plug it into the SetMembers node and it will work just fine. I only used ForEach node to indicate that it does, indeed, work with arrays just fine.
What is your actual issues? Consider posting it in the blueprints sections.