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.
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.
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).
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.)
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.