Download

Stuck in a runaway loop

Hey guys. So what I am currently working on is a hex tile system that generates hexes in a hexagonal spiral formation. Like such:

46d641a3c7915770be1f9667a2cc231bb538c350.png

Edit : If you want to know about the math behind all this http://www.redblobgames.com/grids/hexagons/

This allows as much expansion as you want, all you have to do is set the amount of hexagons. But I am having some trouble right at the moment. My blueprint is causing a run-away loop.
But I have no idea what is causing it. It has been a long day so maybe my logic is just off. Any help would be appreciated.

This is the start
2d0dfc8056471ba405ede4a66a1c43321a00a0de.png

This is where it starts getting the coordinates. The add part is one thing I was trying where I just get the coordinates in an array and then create the tiles base on the array later.

This is another way I was trying where it creates the tiles at the time. I am not sure if it even works because I can’t copy paste the add component part.
9511180c7bd13f4a62231113bc4ee39e84da7e28.png

And this is where each side of the hex ring is created. I unhooked it after the first side to see if that is the problem, but that didn’t fix anything.
873c4e0e5aa64f2e5a7f6cff785d08ec20b8bd53.png

Well if you guys see anything I am blatantly doing wrong I am more than willing to accept criticism. I am pretty amateur at this and I just want to make it work. Thanks.

I just glanced at it, but the first thing I saw was the WhileLoop and I am guessing that is your problem. I would replace it with a ForLoop or ForEachLoop and dynamically set the input for those loops instead of using While. Get that working first and you can come back and try the WhileLoop again. I don’t know why, but anytime I tried using the WhileLoop it caused infinite loops even though I was pretty sure I was updating the the While Bool properly.

Also, I see a ForLoop in your last image that isn’t even connected. Not sure if that could cause a problem.

Generally though, put print strings all around your loops and that should show you the last working component before it goes infinite.

Ya that for loop was just unhooked to see if the infinite loop was in the iterations for the sides. Which it wasn’t because the loop was still infinite. But I will definitely try the for loop instead of the while loop.