Im using raycasting to detect Yposition for tree but i also have to know what material is.
code i used so far:
function getSurfacePosition(posX, posZ)
local origin = Vector3.new(posX, 500, posZ)
local target = Vector3.new(posX, -100, posZ)
local ray = Ray.new(origin, (target - origin).Unit * 750)
local hit, pos, material = workspace:FindPartOnRayWithIgnoreList(ray, workspace.Folder:GetChildren(), false, true)
return pos, hit, material
end
on output i just get terrain
local surfacePos, material = getSurfacePosition(posX+RandomposX, posZ+RandomposZ)
print(material)
ah yes read voxels, most broken command of all time, i tried but cant get it working, i will try again
EDIT:
still cant get it working, i used this:
function printRegion(pos)
region=Region3.new(pos,pos+Vector3.new(1,-1,1))
region:ExpandToGrid(10)
local materials, occupancies = terain:ReadVoxels(region, 4)
local size = materials.Size -- Same as occupancies.Size
for x = 1, size.X, 1 do
for y = 1, size.Y, 1 do
for z = 1, size.Z, 1 do
print(("(%2i, %2i, %2i): %.2f %s"):format(x, y, z, occupancies[x][y][z], materials[x][y][z].Name))
end
end
end
end
can you tell me what garbiage is this: "(%2i, %2i, %2i): %.2f %s"
im sorry man, i dont have time to waste, i have expirience with programing (javascript, C#, phyton, commodore, apple, microsoft basic) and i always use sipler way. can you please tell me what does this garbige: "(%2i, %2i, %2i): %.2f %s"
does and can you tell me why i get error:
13:10:36.784 - Region has to be aligned to the grid (use Region3:ExpandToGrid)