Make looped order out of Array (1-2-3-1) ?


The player should throw 3 “grenades” and then teleport to each one on keypress.

The Shuffle works, but it’s unsafe for gameplay. I’m looking for a node that creates a looped order (1-2-3-1) out of the spawned actors, from the first spawned grenade to the last spawned grenade.


If you want to teleport to only one when a key is pressed, the Foreach Loop is not the way to go, because it teleports you three times each you press X, and you end up at the last array location and you don’t see the teleportation to the first two, because it happens instantly.

From the top of my head I can see two solutions:

  1. Make a Multigate with three execution pins and cycle through them. But it will only work if the number of grenades is always 3 and doesn’t change, since you can’t modify the Multigate when the game is launched. So I guess that’s a bad option really.

  2. Make it manually: create an Int variable and each you teleport, increase in by 1. When the value reaches X (which is the array length), set it back to 0. This way you can have an indefinite number of grenades, and this will work.

I fiddled around for 5 hours trying making an auto-generated array that makes a list out of the spawned actors–, without success. because I get confused as to what the list should do (and what function will actually make the 1231 order)

However, the “Shuffle” node works.

Do you mind showing me a little screenshot of what I am supposed to do? I tried to make variables out of every pin but I just don’t get it.


Could you make an Int array and store 1/2/3.

Run a customer event that pulls “1”, runs that and at the end, add 1 to “Get” and run custom event again. After 3 runs, “GET” resets to “1”.

First Print String is what you want to do, second Print String, is what you do at end of loop.

And because how many grenades are stored in an array, it can be 1 or 500.

Thanks, I will try to understand this.

Right now I don’t understand how to replug or replace those custom events with my ForEachLoop example. Where should I put the teleport function if the entirety is out of custom events?

Hope this makes more sense.You could still use Custom Events or Functions to keep you code clean, but that is up to you. If you used functions, it would look like this.