Landscape generation is making a triangle instead of a square

Hello everyone, I’m trying to generate a landscape, following this tutorial “Terrain generation for Beginners - Unreal Engine tutorial”, but I’m having a little problem, I’m shure it isn’t anything dificult, but i’ve ben looking at the code trying to find the problem for almost an hour, but I just cant find it. The problem I’m having is that my code is suposed to make a grid of debug spheres in the shape of a square, but instead it’s making it in the shape of a triangle.

This is my code:


This is what it does when i simulate it:

And this is what it should do:

Does anyone know why it doesen’t make a square shaped grid?

I managed to solved the problem, the problem was in the “Create Vertices” function, the connection from the set x block to the second for loop, it should look like this:
image

And thanks to RushDarling on reddit for his possible explanation to what was happening, this was his explanation:

Glad you solved it! I’m going to type up my understanding of the problem just to test myself and on the off chance it helps someone else if it’s correct.

Those first two loops in your vertices function are nested loops being used to set out the grid, based on whatever your XSize and YSize variables are. The X-size loop being the outer loop and the Y-size loop the inner loop. Each step in the X size loops through the entire Y loop, so an X of 5 and a Y of 5 will generate 25 points.

0 : [0,1,2,3,4]
1 : [0,1,2,3,4]
2 : [0,1,2,3,4]
3 : [0,1,2,3,4]
4 : [0,1,2,3,4]

That however is assuming the loops start from zero, but in the case that was generating the triangle the outer loop appeared to be passing its current index as the start index for the inner loop, which meant that each inner loop was creating one fewer point at each iteration of the outer loop.
0 : [0,1,2,3,4]
1 : [1,2,3,4]
2 : [2,3,4]
3 : [3,4]
4 : [4]

Have each level centered and you get a triangle.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.