I have an array of vectors and I want to run a function on each vector in the array.
For example, I would like to add 100 to each Y value to each vector in the array upon an execute command.
I have an array of vectors and I want to run a function on each vector in the array.
For example, I would like to add 100 to each Y value to each vector in the array upon an execute command.
I hope this is, what you want. Basicly it runs a loop, which cycles through each object of your array and does something to it. Here I added 100 on the Y-Axis and printed the result to the log/screen. For testing purposes I added an array with 10 objects. The first one had Vector(X=1, Y=1, Z=1) and the last one (X=10 ,Y=10, Z=10).
Here is the result of above function:
Thanks for the reply!
How can I store the new array into an array variable?
Do you mean store the new values into the old array?
Or do you mean to put the new values into a new array?
If you mean the latter, this is how I made it (You first need to create your new array variable, which you use to pass your new values into):
I think we’re getting closer to the solution.
For every execute command, I need to add 100 to the Y value of each vector in the original array. The problem with the ADD node is that it keeps adding variables to the array and increases the index. I just want to run a function to change each element in an array variable, replacing each element with it’s corresponding output from the function.
I think this should be the result you want:
“SetArrayElem” basicly takes your current array, runs through the loop and updates your objects at the right “Index”. I also made a loop previously, where I ran the same function over and over again. The function continued to add 100 and replace the old values with the new ones.
Yes! Thank you!!!
Have fun :).