MakerDoe
(Dez)
#1
I made a script for maze generator that generate walls the problem is that I want the walls to be generated on a center point:
local wallSize = Vector3.new(10, 8, 1)
local offset = (Vector3.new((wallSize.X - 2), -(wallSize.X + 1), (wallSize.X - 2)) / 2)
local position = (self:GetPosition() + ((Vector3.new(row, 0, column) * (10 - 1)) - offset))
local northWall = (Vector3.new(0, 0, (wallSize.X / 2) - 0.5) + position)
local westWall = (Vector3.new((wallSize.X / 2) - 0.5, 0, 0) + position)
Never mind I found a way, took me a whole day to figure it out I don’t know why:
for row = 1, gridSizeY do
local columnPosition = centerPosition -- Temporary position for column
for column = 1, gridSizeX do
local squareIndex = ((row - 1) * gridSizeY + column)
floorProperties["Position"] = (columnPosition + ((Vector3.new(row, 0, column) * wallSize.X) / 2))
columnPosition -= ((Vector3.new(0, 0, column) * wallSize.X) * 1.5)
local floor = createPart(floorProperties)
end
centerPosition -= ((Vector3.new(row, 0, 0) * wallSize.X) * 1.5) -- subtract current position
end