DestructionModule for in-game destruction needs!

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.

DestructionModule

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)

45 Likes

You aren’t forced to use those sounds. Just change them, and add animations yourself.

2 Likes

It looks amazing, but will there be non-voxel destruction module though?

I had to choose between the two; the non-voxel one looks cool but it doesn’t seem to allow splitting walls into little pieces or things like cutting down buildings.

If it did, it would make building things easier so I don’t have to make every wall out of smaller segments.

1 Like

Is this still being worked on? If so, could you provide a place file? I can’t really get it work. :slightly_frowning_face:

sorry for the bump

Wow. This is amazing! I was actually trying to work on something exactly like this! All though I was struggling trying to create things like the voxeliser and welding the parts that are touching. I also highly recommend that you look into greedy meshing! It reduces the amount of parts being created for voxels. Really clever stuff!

image

Here are some good posts that explain how it works pretty well:

Also could we please get an example place (such as the one shown in the video) so we can test out and further learn and experiment with it? Cause I am struggling to use the module cause I have no idea what one of your parameters are suppose to use.

image

what is funcName? (yes I know it’s the name of the function) but is it a string? the function itself? if so, how do interpret them?

Also I love how you are using voxels (which are really special and are an underrated technique for destruction or rendering)
Your title should reflect a little bit more on it. Like throw in the word voxel somewhere

You could go alone the lines of DestructionModule for in-game voxel destruction needs!

2 Likes

A good way to optimize it is only create the voxels in the area that was destroyed.

and then use unions to make the hole for the destroyed area.

because right now. You’re stress testing your PC from all the voxels in one place. So If you do it only when it get destroyed then it’ll be moving and not so graphic heavy.

2 Likes

If you guys are struggling to use it, I have rewritten it and made it easier to use, along with providing documentation and such. Vex | For all of your voxel destruction needs

@Laqotaa @Ethanthegrand14 @lilsquish08

3 Likes