Adding to an Array within a Struct Array - am I doing it right?

Hi there!

So if I have a Struct Array, containing single variables and another array. Whats the best way to add to such Array within the Struct Array?

Everytime I have to deal with it it feels wrong so now Im just gonna ask you guys if Im doing it right and if there is an easier way.

Example: Here I want to add to the struct Index 0, and I want to add something to the array within.
Yellow is usually the way Im handling it. Blue is something I never did before but should work as well.
The need of “copying” the array all the time feels bad. But if you tell me that’s the only way then I can just accept it and continue without headache.
StructArray|690x346

I think you’d be able to simplify using the ‘Get (ref)’ instead of ‘Get (copy)’. Then you wouldn’t have to do the set again at the end. You would be able to modify the version that exists within the original array.

1 Like

In my project. I use something similar, not at my game dev computer, but this is the pseudo code:

Struct array> Create local array variable>for each loop> create local variable for item in array>Get item local variable, split struct output pin> Logic for modifying struct> Get local array>set array elem, split item struct input pin>feed in logic modified variables + unchanged variables in struct item.

For index I use a non changing index for my struct so I can call any specific item from index alone. So I set the index to a number preset in the struct item.

On loop complete> Get local array and set the array originally used.

Personally I’ve found this works really well for doing data modification of struct arrays. Whether this is the best or most efficient, I have no idea.

wow I dont know why but I didnt noticed there is something else beside “get copy” …
jeah… thats what I was looking for :smiley:

Thanks!