array of targets using for loop

I was wondering if anyone had or could provide me with some guidance on how to get an Actor to move through a series of targets in order. I believe I would have to create an array of the type targets, get all their positions, and somehow use a Simple Move Actor to Location in a for loop for each target for the actor to go through each one, but I’m having a bit of trouble dealing with arrays and for loops. Thanks!

You mean something like Chain Lightning or similar?

So first you get it in the Array, such as through a sphere trace or otherwise. If order is important, you will want to get them in order or figure out another way to sort them once in the array. For instance, I put tectonic plates in an array, and then I pull them all out of that array based on size, then put them back into the array in groups of similar sizes, largest to smallest. There are many ways to organize the array to get the order you want and it depends on what you are using as reference.

You can also sort as you run through the array such as checking to see if an enemy is standing in water(Branch), and if so continue executing, or execute with special conditions.

Once you have it sorted, plug your array into a ForEachLoop. Then, it will have an output called Array Element which is what you are going to act upon. So each loop output, you get the vector from Array Element, use the vector to set locations, etc and the loop will do that for each actor. And say you grab 15 targets with your sphere trace, and they are all in your array, but you want your Chain Lightning to only hit 4 of them, you can use the Array Index output to determine how many actors you have gone through and stop it short, as well as many other things.

There is a lot you can do with arrays and loops, so just start small and add to it bit by bit.

I’m not quite yet at the point of which I understand sphere traces fully, and then pluging the data into a ForEachLoop. My problem right now I suppose is that when I study one section, assumes I understand a certain concept in Unreal, and I am infinitely back tracking. Thats why I kind of wanted maybe a blueprint picture. But thanks for your info, I’ll try to use it to guide me on more sections to read on. I’ve bought some classes on Digital-tutors and Udemy, and they are not as helpful as they thought either. The best stuff I’ve seen so far are Tesla’s UE tutorials. I guess back to digging a bit to some older videos and hope I hit something gold. Thanks.

Another target to target idea if it can help : Using blueprint with a box instead of target point (Edit : like in tutorial shown by narghile upon this post ^^). On begin overlap : simple move to next box registered. Pain : need to set all “next box” variables in level blueprint like target points (and i had a lot ^^) but it works fine. (Maybe can you set it in level blueprint too. I used blueprint because i had 4 different characters going through and back and had some logic to had in like choose one of different points or wait when firelight is red and start again when it goes green)

Edit 2 : i remember a thread using splines too to have a multi location point for moves

I use this theory when moving AI to targets.

Merry Christmas


Thanks guys, I’ll try these methods and get back to you.