How do I make proper voxel destruction physics like Teardown?

Ok, I am making voxel destruction physics and have it so each little voxel gets detached from the build you hit. I want some of the voxels to like combine like Teardown, I’ve tried a few things like floodfilling but I can’t really wrap my head around this one. Here is a demonstration of what I have so far.

I want some of the voxels to come off in chunks when I destroy it all.

If anyone knows how to help it would be greatly appreciated, Thanks!

4 Likes

Looks really cool!

I don’t think there’s any super simple way of getting the result you want, but if you don’t mind learning some cool algorithms you could check out Voronoi diagrams. If you can divide the wall into Voronoi segments and detach the one that gets clicked in one big chunk you might get something that looks good.

1 Like

Okay actually that might be overkill, and you could probably get a similar result in this case using a breadth-first-ish but still-a-bit-random flood fill that’s limited to e.g. 10 or 20 voxels. Instead of removing all welds from each voxel that gets smashed, only remove the welds that connect smashed voxels to un-smashed ones.

2 Likes

That’s a good idea, I’ll definitely start with that and then maybe I’ll try splitting up the main chunk somehow

1 Like

It worked! However when you hit it just produces one big chunk so I’m going to try and put some lines through it or something and try to split it up now

1 Like

Dude, I got it completely working!! thanks so much!

4 Likes

So all of your models are just a bunch of squares put together? Couldn’t that be like crazy laggy?

I guess, roblox handles stuff like this bad but not as bad as you think.