Elements in Structure Array not being set in BP

The Array Add blueprint node does not work with vector arrays in Structures (specifically created inside the Editor through the Content Browser). I think my images verify this claim.

My first image illustrates that were attempting to add to a structure array. The 2nd demonstrates that after the Add function finishes, the added random unit vector actually wasn’t added to the array - it’s empty.

Am I doing something wrong? Or is this a bug?

Hi JesseMeyer,

I just tested this in-house and each time I moved the blueprint the value was stored. Try this setup to see it in real-time.

Add a Get after the value was stored and then run your project in Simulate mode. While simulating, move the blueprint around.

Hi TJ.

Thanks for your helpful response. That does work for me. I trusted the debug output - is there a reason why it doesn’t report the array’s contents?

I must admit my real world case is more complex than the example I posted, which does not work. With it, I use an array of structure arrays.

I have modified the working blueprint to better mirror the real usage, and have succeeded in causing it to fail. :slight_smile: Perhaps again I am misunderstanding how Blueprint operate.

Hi Jesse,

Here is the solution we came up with. This may need to be altered depending on how you are planning to use it. The trick is you must set the array size before adding/setting the array elements.

I did this on a Event Begin Play in the Event Graph.

20945-ah_structarray01.jpg

Then set the array elements in the Construction Script.

Thank you! That did resolve the problem.

I speculate the fundamental issue is a lack of recursive parsing of whatever instrument is crawling the node hierarchy logic - forcing otherwise clean solutions to adopt logical cruft to migrate around the problem. Whatever the limitation, are there plans to improve it?

Fundamentally this is just how struct arrays work in the engine. However, we are actively working to improve them and will hopefully streamline this process a bit in the future.

Hello,

I think it’s still broken in 4.9 but I kind of see why, since we use the the “get” node, we declare our operations as “I’m not gona modify this value, just read it”. So it’s logical why does it not work.

With this soulution below, you can set any elements of a struct, and use all the regular array operations even width arrays in arrays of struct (that’s happening in the image).

Just remember, never try to modify something you get out of a “get” node and you will be fine. (of course only if structs are involved :P)