I recently made a thing. Still working on it though but it’s good enough to experiment with.
This is a voxel destruction module that functions by turning parts into voxels and welding them. You can run them at game start or have it done in-game.
Demonstration:
Using it:
Move all the modules out of the folder into the ServerStorage
Call require()
on the DestructionModule
local dest = require(game:GetService("ServerStorage"):WaitForChild("DestructionModule"))
Call destruct()
dest:destruct(hit)
This snippet is from a cannon I made that’ll turn any part it hits into voxels and then welds them together before making an explosion to destroy them. It is the most performant method I’ve found.
The other modules that comes with the package can also be used:
The AutoWeldModule for auto-welding models that are touching but not intersecting.
Call weldParts( object, anchorAfter )
object = Model
to weld
anchorAfter = anchor parts after welding/ default is false
The VoxelizeModule for voxelizing parts or models.
Call voxelize( object, anchorAfter, voxelSize )
object = Model
or Part
to voxelize
anchorAfter = anchor parts after voxelizing / default is true
voxelSize = changes the size of voxels / default is 1
It’s a work in progress but any tips on how to improve performance would be helpful! Also keep in mind the VoxelizeModule creates a lot of Models
in workspace
.
Another thing: using large parts can create a lot of lag; it’s better to turn big parts into smaller pieces (why the small building didn’t lag but the wall did in the video)