Download

Reverse Array or read Array backwards?

Is there a way to read an Array backwards or reverse it (First Index becomes last index, last index becomes first index and so on)? I have a working Blueprint that Generates a random Dungeon. To avoid placing a Tile on another Tile, i safe the position of the Tile in an Array and everytime i create a new tile, i check if the position is already taken. However, this is very inefficient, because the position I am looking for is often at the End of the Array. For example, when i generate 600 Tiles my Blueprint has to check 1+2+3+4+5…+600 Positions (that´s the optimal case. Normally i have to do this 3 times). If I could read the Array backwards, the Blueprint would find the position much faster. The 600. Tile has to check about 580-599 Tiles until it finds the Position. When reading backwards, it would find the position after 1-20 checks.

Nevermind, i just solved it myself by adding a Counter. In case somebody needs this:

Maybe a For Loop with reversed values (from last index to 0)? Never tried that one :stuck_out_tongue:

Use a for loop and feed this to a “Get” node:
(Array lenght -1) - loop index]

All one loop. No breaks involved.

“Reverse for each loop” nod for this. Yes, I see date af this topic, but its first url in google search.