I have an array within a structure array which elements can not be set. I am using UE 4.6.1.
Create a new blueprint structure.
Add to that structure an integer-array and add to that integer array an element by default.
Create an array cointaining one new structure.
Try to change the value of the element held by the integer array within the new structure. It doesn’t work, at least not for me…
Is this a bug or am I missing something? Thanks in advance.
Let me know if I’m reproducing this wrong but this works for me.
I create the Struct with some Integer values.
Then I created a blueprint that allows be to print > change > and then reprint that value.
Does this setup work for you?
Thanks TJ for your answer and sorry when I didn’t made myself clear, but the struct needs to be also in an array! Here ist my setup and the output log which shows 1 twice although the element is set to 500
Okay, I think I see now. Try this:
- Create your Struct that contains the Int Array.
In the Level blueprint, create a variable of that Struct type.
Make sure to Compile and then click the + sign at the bottom of the Details panel to make sure that the Struct is actually added to the Array.
- Create this blueprint that pulls the Struct out of the Array variable, then pulls the Int Array out of the Struct. You can then set any Int Array element and see the change.
Let me know if that works or not. Nested strucs/arrays can be quite confusing, if I’m not understanding correctly please bear with me and we can keep troubleshooting.
Doesn’t work for me in 4.7.6 - I used exactly the same setup. Here’s the project: Cahoots — Ann Arbor tech coworking
I’ve also noticed that when I close the project and reopen, the Item pin starts to look like a byref pin:
This is a known issue that is currently being investigated. You can find additional info on it here.
I’ve found a workaround for this. The solution is a bit awkward, but it should do the trick for people like me who have desperate need of nested arrays. The way you do this is to set a temporary variable to your struct array, modify this temporary array and then set this value back into the larger array. Here is how to do it for Set Array Element, though the same principle applies for manipulating the array in other ways. I hope someone will find this helpful until Epic finds an official solution:
Thanks Monokkel, you just saved me from wasting another two hours. This issue is well alive in 14.1…
Isn’t it because primitive (String, Integer) arrays get copied by value? Meaning any change on an array you just got from a struct is just a copy of the array the struct itself holds. Along with the fact that each separate usage of the array is a new copy of the original array of the struct itself. These explain the behaviour and suggest: Great copy constructors and loving passing by value