Terrain FillBlock inaccuracy

I’m having trouble with the FillBlock function.
Whenever I fill a region with terrain, there’s some inaccuracy.

In this video, the red part is a visualization of the size and CFrame of the water, filled with Terrain:FillBlock().


The water level is higher than it should be.
Sometimes it does this, sometimes it doesn’t. There doesn’t seem to be a pattern in this behavior.

Here’s my code:

for _, WaterLevel in pairs(Chunk.WaterLevels:GetChildren()) do
	if (WaterLevel:IsA("BasePart")) and WaterLevel.Name == "WaterLevel" then

		local WaterPos = Vector3.new(ChunkPos.X, WaterLevel.Position.Y, ChunkPos.Z) -- This position is accurate.
		local WaterCF = CFrame.new(WaterPos)

		local WaterSize = Vector3.new(ChunkSize.X, WaterLevel.Size.Y, ChunkSize.Z) -- Size is also accurate.

		Terrain:FillBlock(WaterCF, WaterSize, Enum.Material.Water)		
				

        -- Test part to visualize the water cf and size.
		local Tp = Instance.new("Part", workspace.Temp)
		Tp.Anchored = true
		Tp.CanCollide = false
		Tp.Color = Color3.fromRGB(255,0,0)
		Tp.CastShadow = false
		Tp.CFrame = WaterCF
		Tp.Size = WaterSize
	end
end

Can I do something about this? Or is this just a thing that terrain does?

Terrain is locked to an independent 4x4x4 stud world grid. It does its best to fill the block, but it has to round to the grid. If you move everything else up a stud or two, it will align on the Y axis with the red block. That’s all you can really do though.

1 Like