Many people usually ask how to create voxel destruction in Roblox, but that’s easily accessible nowadays with the multiple open source modules. I’ve run into a problem myself with creating optimized voxel debris from the voxel destruction that is not laggy and is smooth on all clients. A game that does this very well is Jujutsu Shenanigans ([CURSED PARTNERS] Jujutsu Shenanigans - Roblox)
Some notes that I have:
They are doing client sided interpolation on debris, this is apparent as there is a setting they have that enables and disables client sided debris interpolation for performance.
This means that they are creating “debris” (might just be a table of positions and velocities) on the server and then syncing it to all clients
This is also apparent as all clients have the same debris piles when a building is destroyed.
They do spawn ALL voxel debris for destructions that dont out-right delete debris.
They anchor parts after they no longer have any movement to reduce the amount of un-anchored parts in workspace
As you can see when it’s off the debris parts are laggy, this could mean they are sending snapshots to the client on where the debris should be.
I’ve tried many things to try and replicate this system, but no matter what I do I cant seem to get the performance they have.
I tried making it so that the server just creates tables that serve as “parts” but really just consist of velocities and cframes. The glaring issue with this method is that the clients would control collisons, which would lead to inconsistent debris piles on other clients
I tried making it so the server just spawns an invisible, collideable part for debris, then sends snapshots of that debris part to all clients in intervals so that they can interpolate its position. The clients would create an anchored, non-collideable part that would interpolate the servers part position as it receives snapshots of it. This would lead to smooth and synced debris for clients, but it was incredibly costly and not performant at all.
At this point I’m stumped on what to do next so I made this post to see if anyone here can help me solve or get an idea on how to solve this issue.
Have you tried sending an event to tell the client to do all the destruction there? I’m not sure if sending snapshots every few frames from the server will ever be performant.
I have. My first initial method was to create debris on clients by telling them what had been destroyed and for them to just create the debris there. That doesn’t solve the unsynced debris though with each client having a different looking debris pile.
Not really, no. I scrapped the whole system. I’m not really looking for debugging here more of just an idea of how games like Jujutsu Shenanigans are able to spawn so much debris without lag, while having it synced to other clients.
They likely used a similar system to what you described then if all the client parts are synced. I believe it’s the implementation of the system that’s causing performance issues more than the actual concept itself.
I have a similar system, which precomputes sizes locally for new parts, does the ray-casting locally, and sends that to the server. You can even precompute the carve instruction locally - I haven’t done that yet. I’m sure you can do the part bounds calculations for anchored/unanchored logic locally, too.
I already do the carve instructions locally as well, then send it to the server to sync with other clients. What do you mean ray casting locally? What are you raycasting? Also what part bounds calculations are you talking about? Do you mean to calculate the bounds of every part to simulate collisions?
Like the part the user is looking at end, you can verify with distance on server.
What are you raycasting?
The precise position of hit, from like tool or something that triggers the voxel destruction. Verify on server with something lighter than raycasting.
bounds calculations are you talking about?
So, I’m checking every new created part with GetPartsInBounds for their cframe and size + small vector3 elipsoid, to find how many faces touching. And based on its size and amount of faces touching, I’m determining if should anchor or not.
However, I found this is not that optimal it leave floating chunks in the air sometimes.
So I think maybe is best if you create an array and save parts that are touching either the newpart or part that touching the newpart