So I’m making a placement system with a grid, but the model position just doesn’t want to fit with the grid
This is the code I’m using
local function GetSnappedVector(vector: Vector3, gridSize: number)
if vector and gridSize then
local canvas = plot.Canvas
local canvasSize = plot.Canvas.Size / 2
local primarySize = currentModel.PrimaryPart.Size / 2
local relative = canvas.CFrame:PointToObjectSpace(vector)
relative = Vector3.new(
(math.round(relative.X / gridSize) * gridSize),
relative.Y,
(math.round(relative.Z / gridSize) * gridSize)
)
return canvas.CFrame:PointToWorldSpace(relative)
end
end
BTW: the texture it’s aligned but the problem comes with the grid calculation thing, I tried adding half of the grid size and it worked but it looks awful