Hello there, I have been having an issue trying to figure out how to actually create some sort of triangular terrain through terrain generation. I am currently using wedges as the example brick
to generate the rows.
Here is the code:
function MakeTriangularTerrain(dummyPart, row, column, parent) local triangleStartPos = dummyPart.CFrame; local currentRow = 1; local currentCol = 1; for Row = currentRow, row do wait(); local triangleWedge = dummyPart:Clone(); triangleWedge.Parent = parent; triangleWedge.BrickColor = BrickColor.new("Really red"); triangleWedge.CanCollide = false; local rowTriangle = triangleWedge; local rowSize = rowTriangle.Size; local currentCFrame = triangleWedge.CFrame; --rowTriangle.CFrame = currentCFrame; rowTriangle.Orientation = Vector3.new(0, 90, -90); if Row%2 == 0 then rowTriangle.CFrame = currentCFrame * CFrame.new(0, (rowSize.Y * Row)/2, 0); rowTriangle.BrickColor = BrickColor.new("Bright green"); rowTriangle.Orientation = Vector3.new(0, -90, -90); end currentCFrame = rowTriangle.CFrame; end end MakeTriangularTerrain(workspace.TestTriangle, 3, 1, workspace);
Basically, my issue is after spawning the green wedge part it actually does spawn the rotated red one but doesn't move it to the next position, I am currently not seeing how to reset the position and set the new position so it actually does as shown:
Any help to enlighten this a bit more is apreciated!
I believe what you did is forget to add an actual function for the red triangles to be positioned. In studio I tested this script out and came up with this (it has manual mathematics, I didn't generate the positions or anything, so you might want to change that):
function MakeTriangularTerrain(dummyPart, row, column, parent) local triangleStartPos = dummyPart.CFrame local currentRow = 1 local currentCol = 1 for Row = currentRow, row do wait() local triangleWedge = dummyPart:Clone() triangleWedge.Parent = parent triangleWedge.BrickColor = BrickColor.new("Really red") triangleWedge.CanCollide = false local rowTriangle = triangleWedge local rowSize = rowTriangle.Size local currentCFrame = triangleWedge.CFrame --rowTriangle.CFrame = currentCFrame; rowTriangle.Orientation = Vector3.new(0, 90, -90) if Row%2 == 0 then rowTriangle.CFrame = currentCFrame * CFrame.new(0, (rowSize.Y * Row)/2, 0) rowTriangle.BrickColor = BrickColor.new("Bright green") rowTriangle.Orientation = Vector3.new(0, -90, -90) else triangleWedge.CFrame = currentCFrame * CFrame.new(0, ((rowSize.Y * Row)/2)-1.4, 0) triangleWedge.Orientation = Vector3.new(0, 90, -90) end currentCFrame = rowTriangle.CFrame end end MakeTriangularTerrain(workspace.TestTriangle, 30, 1, workspace)
The part where you put "Row%2 == 0" means that it divides the row by 2 and if the remainder (which will only be either 1 or 0 because it's even/odd integers) only moves when it reaches 0, which is every even number (For example: 1 is the placekeeper but when it gets to 2 it's positioned, then 3 it skips because it's odd, then it goes to 4 and so on...)
Hope this helps! (My first post so I sure hope so lol)