I’ve been working on a grid building system, and I’ve come across an issue. I can’t seem to figure out how to make the grid system work with multiple sized objects. For example, in Blockate. That game has varieties of block sizes. Full (4, 4, 4), Slab (4, 2, 4), Small (2, 2, 2), and Pillar (2, 4, 2). How would I modify my current grid system to achieve this goal?
local function ReturnCalculated(Offset)
local Target = Mouse.Target
if Target then
local convertedCF = Target.CFrame:ToWorldSpace(Offset)
return convertedCF * Rotation
end
end
local function CalculatePosition(targetSurface)
local GridX = CurrentPlaceholder.Size.X
local GridY = CurrentPlaceholder.Size.Y
local GridZ = CurrentPlaceholder.Size.Z
if targetSurface == "Front" then
local convertedCF = ReturnCalculated(CFrame.new(0, 0, -GridZ))
return convertedCF
elseif targetSurface == "Back" then
local convertedCF = ReturnCalculated(CFrame.new(0, 0, GridZ))
return convertedCF
elseif targetSurface == "Left" then
local convertedCF = ReturnCalculated(CFrame.new(-GridX, 0, 0))
return convertedCF
elseif targetSurface == "Right" then
local convertedCF = ReturnCalculated(CFrame.new(GridX, 0, 0))
return convertedCF
elseif targetSurface == "Top" then
local convertedCF = ReturnCalculated(CFrame.new(0, GridY, 0))
return convertedCF
elseif targetSurface == "Bottom" then
local convertedCF = ReturnCalculated(CFrame.new(0, -GridY, 0))
return convertedCF
end
end
Those scripts above are my main functions used to calculate positioning. It also includes my attempts to counter this issue.
Edit 1: Objects that are normal sized also have issue being placed onto smaller objects.