Changing a single element of a struct?

I have a large stuct which a then made an array of. I want to change a single struct variable of a single array element.

I can do easily in C++, but I’m trying to learn blueprints. I can also do it in blueprints too, but the way I’m doing it seems wrong. It works, but there MUST be an easier way.

What I do now is get the array, input the index for the array element I want to change, then I use the “set array elem.” Then I have to split the pins and connect every single pin from one to the other, making the change to the variable(s) that I want to change. Here’s what it looks like:

In this particular example, I’m changing multiple variable, but sometimes I only want to change a single one. Is there a simpler way to do this in blueprints or must I connect each and every pin each and every time?

Set Members in Struct is the name of the game.

  • only the exposed pins have their data modified
  • do note that blueprints copy a lot; round icon is a copy, diamond is a reference

Here, ForEachLoop makes a copy, be mindful of that - that’s why we need to push the struct back in to the array.

This is not an issue for just one struct, though:

One last thing, since you’re iterating using a Get node:

You can actually get by ref.

1 Like

Ok, sweet. That is a lot easier.

But dang you, now I got to go redo a lot of code. :disappointed_relieved:

Seriously though, Thanks again for your help.

1 Like