Download

Sorting through an array of numbered components and getting their locations

I’m posting this as I research incase someone has done this before cause I’ve been trying all morning to get this right to no success and feel its a tough nut to crack without good string parsing.

I have 10 arrow components in a blueprint named Tube1, Tube2, … , Tube 10.

I use GetComponentsByClass(ArrowComponent) and put them in an array. They need to be in order and I then need to get their vectors (relativeLocation) and create an array of those locations that match the 1,2,3, etc… 10… setup so Location[0] is == to ArrowCompArr[0] etc.

Of course if they arnt ordered properly, which they never are they dont order properly. Im using locations 1,1,1 2,2,2 3,3,3 etc. to debug.

Heres what I’ve played with most recently, trying to sort 3 ways.

Does anyone have any tips for getting this setup right?

Sorry about the mess, tried to fit it on one screen. I have the vector array variable, and th elocal variables, and you can see the arrow components intentionally in disorder.

http://i.imgur.com/fMK9CQj.png

Yes what a mess! :smiley:
Have you tried using “Set Array Elem”?
Plug the index from your loop into the index of both nodes/array and maybe use “Size to Fit” in case you have not set the array size manually.

In case its still not working, i would like to see what is happening and maybe your array setup.

Yeah I tried to squeeze it onto one screen plus a morning worth of attacking one problem.

I ended up getting the components seperated from other arrow components, but couldnt sort them by name numerically…

Will try again in the AMfor a bit otherwise I’ll make some sort of scene component that has a vector I can use…

I suppose the object name contains the numbers?
Try rename them from 0 - 9 and use GetSubstring and cast it to integer.

Finally got it, it took 3 arrays to get the list into one final array of relLocs of these components but now its prototyped and no code smell and future proof.

Set array elem helped alittle, thanks. It was displayname vs object name that got me. Object name made it much easier. Just trim Tube from tube1,2,3,4 etc and sort the remaining numbers.

Array sorting and string parsing doesnt lend itself well to blueprints.