Alright I am shocked about this blueprint array management. I spent some hours troubleshooting this and turns out it has something to do with memory management and possibly a bug.
A bit of background, I spend alot of time programming in javascript and its been awhile since I’ve done c++. That is an aside, but relevant when considering how arrays are allocated and retained in scope automagically in javascript.
I thought I could take that same concept here to blueprints with a high level algorithm of;
“declare an array buffer, add some stuff to it, save it for later”.
After troubleshooting my own actual blueprint, I created these 4 experiments to determine what the heck is going on with arrays. These experiments should result in "final length 3 with new id 7"
when successful, indicating the correct number of elements and the proper expected order.
BEGIN EXPERIMENT A
restore id 8
restore id 9
final length 1 with new id 7
BEGIN EXPERIMENT B
final length 1 with new id 7
BEGIN EXPERIMENT C
restore id 8
restore id 9
final length 3 with new id 7
BEGIN EXPERIMENT D
restore id 8
restore id 9
final length 3 with new id 7
We can see that experiment A and B both fail. What they have in common is using the “make array” node. Which appears to preallocate a fixed length at creation time. The Add/Append nodes appear to work without error, BUT THEY DONT. They actually just erase the last value instead of appending and altering the size of the array.
So I am thinking that I need to make a paradigm shift and change the way I deal with arrays in blueprints. Hence the success in experiment C & D; they merely allocate the variable as a local function variable or blueprint variable. There must be some kind of difference between the two, and it would be helpful if the node context explorer didn’t mislead us in this way since the resulting entity from “make array” node is not the same as using variable arrays of the same type!
Experiment A
Experiment B
Experiment C
Experiment D
Disclaimer: technically experiment b would expect 4 array elements in the screenshot, but nevermind that cause it fails to ever get past 1