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

I just checked yeah a lot of the parts are unanchored. I do have attributes but does having it unanchored affect it?

I should have made some sort of check to anchor parts while they break then return them to their previous anchored state. As of right now any part you want to be destructible must be anchored, but I will change the module so that you can break unanchored parts soon.

Also if you want to make an entire model destructible you can put the attribute only on the model and all parts which are descendants of that model will be destructible. I’m not sure if having the attribute on parts and the model causes problems but for now just keep it only on the model itself.

Sorry about that, I should have clarified this in the doc and I will add a fix for these soon.

Do you plan to implement ObjectCache? If not, you should.

I actually did think about it, I’m assuming its better than PartCache, if its able to relieve some of the gittering look of positioning parts I’ll implement it with the next version.

1 Like

Can’t guarantee it but it’s code is more optimal and less cluttered than partcache, and it has bulkmoveto built in, so it should have noticeably better performance if you implement it right

I think this is a interested related effect for those who wish to do shatter physics. I intend to use this to make smashable windows.

Alright everyone, I usually don’t ask any questions about updates as I already know what I need to add but I plan on rolling out a decently large update and want to include any ideas sooner than later. I will be replacing part cache with object cache, including features for mesh part support for making hitboxes, wedge breakable parts, breaking unanchored objects, a crack/shatter method as @Magus_ArtStudios suggested for glass, and my most anticipated- a weld feature allowing breakable parts to drop welded collections of less mass.

If there are any features that you would like to see or think would benefit others reply with them and I will consider including them in V2.

3 Likes

not really, probably just set up a test place with pre-made tools like voxbreaker so people can test your module without having to set it up themself

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