VoxelDestruct | Voxelated destruction physics with greedy meshing, hitboxes, and more!

Hmmmm what about slice feature? So that I can use it for cut any part that use metal material only for lightsabers like from Star Wars movie series.

What does lock, freeze and other stuff does? Edit: Nevermind I am stupid

I am making API to smoothly migrate from VoxBreaker to this module! Will release soon(ok it will take more time)

1 Like

Wrote it like in 3 minutes…

--Not done
local RunService = game:GetService("RunService")
local Signal = require(script.Parent:WaitForChild("VoxelDestruction"):WaitForChild("Signal"))
local Settings = require(script.Parent:WaitForChild("VoxelDestruction"):WaitForChild("Settings"))
local VoxelDestruction = require(script.Parent:WaitForChild("VoxelDestruction"))
local VoxBreakerAPI = {}
local Hitboxes = {}

function VoxBreakerAPI:CreateHitbox(Size : Vector3, Cframe : CFrame , Shape : Enum.PartType, MinimumVoxelSize : number , TimeToReset : number, Params : OverlapParams)
	local debris, walls = VoxelDestruction.destroy(Cframe, Size, Shape, Params, MinimumVoxelSize, math.huge, nil, false, TimeToReset, false, false)
	return debris
end

function VoxBreakerAPI.CreateMoveableHitbox(MinimumVoxelSize : number, TimeToReset : number, Size : Vector3, Cframe : CFrame , Shape : Enum.PartType, Params : OverlapParams)
	local Hitbox = Instance.new("Part", Settings.debrisContainer)
	task.spawn(function()
		Hitbox.Shape = Shape
		Hitbox.Size = Size
		Hitbox.CFrame = Cframe
		Hitbox.Transparency = 1
		Hitbox.CanCollide = false
		Hitbox.CanQuery = false
		Hitbox.CanTouch = false
		Hitbox.CastShadow = false
		Hitbox.Anchored = true
		Hitbox.Name = ("Hitbox%s"):format(tostring(math.random(1, 999999999999999)))
		table.insert(Hitboxes, Hitbox)
	end)
	local HitboxActual = VoxelDestruction.hitbox(Hitbox, 0, false, false, 1, Params, MinimumVoxelSize, nil, nil, nil, TimeToReset, nil, nil, nil)
	local Touched = Signal.new()
	HitboxActual.Collision:Connect(function(debris, walls)
		Touched:Fire(walls)
	end)
	HitboxActual.WeldTo = function(part)
		task.spawn(function()
			if RunService:IsClient() then
				local connection = RunService.RenderStepped:Connect(function()
					if part then
						Hitbox.CFrame = part.CFrame
					end
				end)
				local connection2 
			else
				local canRun = true
				local connection
				while canRun do
					if part then
						Hitbox.CFrame = part.CFrame
					end
					task.wait()
				end
			end
		end)
	end
end

return VoxBreakerAPI

Still works though
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

1 Like

Isn’t VoxBreaker having a major update too?

yeahhhh but I just made an api to fastly migrate from breaker to this since this module is actually more perfomant

Do you know how to make voxels exactly the size you want (1.5, 1.5, 1.5)? They become bigger or smaller relative to the wall.

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅
it splits these into really tiny and thin parts, omg it also lags so much on tiny objects


like this, its so bad actually (yep its worse than voxbreaker in optimization)
like what is this:
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

bro like what is this???
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

There’s an issue with an update I pushed, I’m working on fixing this.

1 Like

waiting for fix my sweetie, I really like your module and looking forward to do some contributions

but you updated it 2 months ago
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Fixed the no meshing bug!
Sorry.

Did you update the model?
or whar Edit: now module doesnt return anything
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅
Edit 2: nevermind i forgor to change attribute
Edit:3


Edit:4
Why does this happen with gridlock on?
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Why the hell it counts big floor as a debris???


Ok what the hell:

As long as parts are anchored and the attribute is set correctly then there should be no odd occurrences. If the floor is being broken then that means its either parented to an instance which has the attribute or it has the attribute itself.

Turn gridlock off if you don’t want very thin pieces, its an unexpected result from floating point decimals, kind of a tricky thing to fix. Gridlock was intended for neatness so its not a necessary feature to use anyway and I may just remove it.

I updated the model with a bug fix that should bring any lag down so try it if you haven’t already.

no each part is separated and is not parented to other parts so i dont know whar are you talkin about