Cube Generation - Infinite Loop Problem

Afternoon all, Thanks for taking a look at my problem!

I am currently toying around with some very small scale cubed map generation and seem to have come across a bit of a stumbling block, which has had me racking my brian for nearly a week trying to come up with solution to get around this infinite loop problem. At the moment, I am generating blocks using the instanced static mesh component which poses a few problems in regards to storing previous column heights and things, hence why I am trying to implement this work-around.

So the following break-down is a overview of how it should work:

  1. Add x number of cubes to the right and left of the 'Master Cube'. [Working]
    
  2. For each cube added in step 1, add x number of cubes above array item. [Working]
    
  3. Add x rows of cubes infront of 'Master Cube' to create rectagular play area. [Working]
    
  4. For each cube added in step 3, carry out a line trace to identify if there is a blocking hit to the left of the cube, if TRUE then add cube above array item, if FALSE then stop adding cubes above array item and delete the last added cube. [Not Working]
    

Step 4 is where I am running into problems, as I need the adding of cubes above the array item to continue until the line trace returns a false blocking hit and I just cant seem to jimmie anything together which will not kick up an infinite loop warning.

Below is a snapshot of the blueprint as is, I have added and removed so many different variations of branches and while loops that I had thought would work but I have had no real success thus far. So the image is just the general operation without the looping involved, hence why I have come to you guys to recommend a suitable method.

Link for ease: http://i.imgur.com/py5sqKp.jpg

My problem seems to be detecting when the line traces are coming up false and then getting out of the loop with that item of the array, if that makes any sense? For example, we enter step 4 of the process and start adding instacnes above item 1 of the array, then once the line trace returns a false a boolean variable would switch to false, completing the while loop, however I need to be able to enter that loop again with the second item of the array, so I set the boolean variable to true for each item of the array and I believe this is where the infinite loop is originating.

Ach, I dont know but if anybody would like to take a look at the wall of text above and try and help out, that would be greatly appreciated!

Thanks, Connor.

You probably want to reset bInitialPass on completion rather than each time you enter the loop body.

From what i gather, youre simply making an x by y grid of cubes correct? Why not just use a 2D array and spawn them with a pair of for (each) loops?

You seem to be going about this in an overly complicated way when you can just spawn them in a logically precise fashion

That’s probably what you need to do, also check this post: [Free] Tiny Blueprint Minecraft Clone - Source - Programming & Scripting - Epic Developer Community Forums

Hi folks,
Thanks for the quick responses.

The bInitialPass variable is being used to switch between adding an instance above either the item in the array or the newly added instance.

Apologies if my initial post was not very clear, what I am trying to achieve is the generation of a x by y by z grid of cubes, in which the z or ‘height’ is determined using line trace results from each newly added instance.

Thanks Zarkopafills,
I shall take a look.

3D array then?

Also, if im reading it right, you will NEVER go through the “true” branch becauae you ALWAYS set bInitialPass to false BEFORE you pass the branch.

Hi 6ixpool,

It is so typical that once I make a post to the forum, I seem to have resolved my issue.
Was just a case of looping back a branch to and changing a few things.

Once it is in a good state, I’ll post a photo up here for anybody who might need it going forward!

Thanks again,
Connor.