Setting variable inside a struct array - Not working

It’s because you passed a copy of the struct instead of a reference, which is what the set member node requires. So you were setting the variable of a “floating” copy. In your fix, when you set the array element, you replaced the original with the copy, which is why it works.

You should be able to convert the element pin from a pass-by-copy to a pass-by-reference, but an alternative is this: break the struct from the array element pin (or you can right click the element pin and select “split struct”), then on the set array element, put a “make struct” node. Then plug the two nodes together with the variables you don’t want to change, and plug new values into the ones you do want to change. This is more hand-work, but I think it’s more performant since you’re not making a copy.

3 Likes