Possible bug: arrays within a structure array

I have an array within a structure array which elements can not be set. I am using UE 4.6.1.

Reproduction:

  1. Create a new blueprint structure.

  2. Add to that structure an integer-array and add to that integer array an element by default.

  3. Create an array cointaining one new structure.

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

Hi XNAShaker,

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?

Cheers,

TJ

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.

Thanks,

TJ

Doesn’t work for me in 4.7.6 - I used exactly the same setup. Here’s the project: Cahoots — Ann Arbor tech coworking

41667-byref.png

I’ve also noticed that when I close the project and reopen, the Item pin starts to look like a byref pin:

Hi CodeSpartan,

This is a known issue that is currently being investigated. You can find additional info on it here.

Cheers,

TJ

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:

http://i.imgur.com/n4WZyhT.png

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