hey this is my first forum post, kinda new to this thing. i tried looking on the forums but i did not discover the exact issue im encountering
-
What do you want to achieve? Keep it simple and clear!
better depiction of voxels. i find it hard to accurately read voxels with parts converted to region 3’s, while it works its not 100%.
i am creating a digging system that involves voxel destruction and im looking to get to feel not jank. i feel like this might be a limitation with the resolution being locked to 4 studs but im not sure so im posting here
-
What is the issue? Include screenshots / videos if possible!
i am reading the voxels and then using fillregion() to get an accurate display on how many voxels has been destroyed and what type but it feels extremely jank and has issues
https://gyazo.com/5e70d2371c40e68d84403702c0342cc6.mp4
https://gyazo.com/5fe4aa6299a9c66acba3b7478bb576f4.mp4
https://gyazo.com/844afd1ba690502659e90f29995500ab
while it works SOME times it isnt very satisfying lol
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i have tried a few other solutions, the only one that seemed to work was using fillblock() while that worked perfectly for destroying voxels, it was difficult to get it to accurately give a reading on what voxels have been destroyed and or modified. (either not even detecting them gone or detecting too many / duplicates)
i have also tried looking across the dev forums, and googling it/ searching through reddit but i cannot find anything with the exact issues as me
i appologise for the whitespace lol
----------------------------------------------------------------------------------------------------------------------------------------------
local size = digger.Size
local region = Region3.new(digger.Position - size/2, digger.Position + size/2)
--terrain:FillRegion(region,4,Enum.Material.Air)
local voxelData = terrain:ReadVoxels(region, 4)
local function voxelFunc(voxel)
if not canDig then
return
end
local highestMaterial = nil
local highestCount = 0
voxelDetected = voxelDetected + 1
if _voxelDestroyed >= MaxCapacity then
return
end
if voxelMaterial[voxel.Name] then
voxelMaterial[voxel.Name] = voxelMaterial[voxel.Name] + 1
else
voxelMaterial[voxel.Name] = 1
end
for material, count in pairs(voxelMaterial) do
if count > highestCount then
highestCount = count
highestMaterial = material
end
end
materialDisplay = highestMaterial
_voxelDestroyed = math.min(_voxelDestroyed + voxelDetected, MaxCapacity)
print(_voxelDestroyed)
terrain:FillRegion(region, 4, Enum.Material.Air)
destructionPercentage = _voxelDestroyed / MaxCapacity
--voxeltoVisual(destructionPercentage)
end
----------------------------------------------------------------------------------------------------------------------------------------------
--get voxel information
for x = 1, #voxelData do
for y = 1, #voxelData[x] do
for z = 1, #voxelData[x][y] do
local voxel = voxelData[x][y][z]
if voxel.Name == "Air" then
return
end
voxelFunc(voxel)
end
end
end