I have a map that contains structures as values for quick access via IDs. In my tick, I need to update all structures. Therefore I create a For Each Loop that iterates over all values of the map.
Now I notice that this has no effect because the structures returned by the VALUES node are copies of the structures in the map. Whyyyyy would Epic do this? Why are structures not used by-ref as a default and only cloned when specifically requested? Not only makes this the blueprints needlessly more complicated, it is also slower. Whyyyy?? I want to understand why anyone would build it in this way.
Man, it’s so bad. I don’t get how you can build such a nice visual coding language that abstracts everything and then they don’t abstract this super basic behavior that is standard in every single programming language except C/C++.
Shouldn’t, since I don’t want to reorder or manipulate the array, only the content of an element.
I think the reason is because structs are passed by value by default in C++. There are more problems related to this, not only with Maps / Array. For example you can pass a structure parameter into a function and mark it to be passed by reference. However, if you store that structure parameter in a local variable in that function, the reference is lost and all changes to the structure are on a copy. So you can’t store it in a temporary variable, and instead you have to drag the original parameter pin all over your function if you want to make changes to the reference. That’s just… sad. I haven’t found a way to save it by-ref in a local variable, it’s always a copy.