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.
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.