Hey, devs!
I’m making a Minecraft-like voxel game and working on a block placement system.
This is my local script function to calculate the snapped pos from the hitPosition
function getGridPosition(hitPosition)
local gridPosition = Vector3.new(
math.round(hitPosition.X / 4) * 4,
math.round(hitPosition.Y / 4) * 4,
math.round(hitPosition.Z / 4) * 4
)
return gridPosition
end
I have a problem that sometimes it rounds badly and the position is wrong.
Does anybody see some problem in that function?