Union starts lagging after being subtracted a couple times

So, I am trying to make something kind of like this game:

https://www.roblox.com/games/6058150350/Destruction-Physics

It works but after the part is subtracted a couple times (image) it starts taking a while to subtract.

So in this gif, you can see that after a couple times of me doing it then it starts taking a while

8krZLjwmhZ

Any ideas how to fix this? I do not want to switch from unions as having a ton of parts would make it very hard to make the script. I have tried looking on google but found nothing sadly

This is using subtractasync

2 Likes

Bit of a late reply, but you can’t really get around the horrible performance of live unioning in roblox. Even destruction physics itself lags a lot. If you made each of your negatives only one part, the performance would be greatly improved (but still slow down eventually). This is because CSG (what unions are) has to store each of the parts that make itself up and use those parts in further calculations, quickly spiraling out of control in terms of complexity.

The new CSG v3.0 greatly improves on the speed of these, but still has much of the same performance issue at high part levels (just due to the nature of CSG). However it’s in beta and beta features can take ages to release to the public (if they do at all), so you shouldn’t rely on them for making a game. Even with simplified unions as you can see in destruction physics, performance becomes a real issue with only a few players.

If you’re set on this voxelized look, I’d suggest just using voxels and greedy meshing (which could have much better live subtraction performance than unions if you chunk the part and cache voxel parts). Marching cubes is similar and can also work, but has performance issues of its own due to the huge amount of parts needed. Beware of using parts in those methods I listed for moving applications. I’m working on a making a destructible vehicle system for my game, and I’ve spent several weeks exploring different avenues, only to find out that ~1000 parts moving at the same time strains the render pipeline to unplayable levels (collisions turned off), due to the updating and re-rendering of those part positions on the client.

Basically, you can’t get around this, and it won’t improve until CSG 3 finally comes out, and even then it will still be an issue. Only thing you can really do is reduce the amount of parts you subtract and chunk what parts you can.

3 Likes