VoxBreaker | An OOP Voxel Destruction module

i think trying to make it not lag on lower end devices is gonna be hard

1 Like

I’m gonna try a few more methods, I’ll let ya’ll know if I can fully optimize this!

1 Like

You should try using that one part cache module that used BulkMoveTo, I think FastCache? So instead of creating new parts youre pulling and returning parts from the cache (faster because BulkMoveTo)

If that still is bad for low end, id try checking the microprofiler to see what exactly is the bottleneck, and optimize that.

1 Like

i think it’s ObjectCache

2 Likes

I tried objectcache but some voxels that were created with it ended up becoming nil for some reason

1 Like

you can try to, but parts will always just be parts and physics will be physics. i do know that jjs uses partcache (so maybe if you use objectcache, you might get even better results than jjs). but, one thing that jjs has over this module is i guess the algorithm for the voxelization, or maybe it’s greedy meshing. i’ll show an example of the algorithm of this module compared to how jjs’ destruction module does it


jjs has like more than half the part-count than voxbreaker and it kinda pains me to see this algorithm from voxbreaker because i use this myself personally :sob: and yes i did implement greedy meshing to the creator marketplace version of voxbreaker with the help of non-voxel greedy mesher and did it by just tagging the partTable in “CreateHitbox” with “Debris” and having the greedy mesh not mesh parts with the Debris tag. but the destruction after the mesh was so scuffed, that i gave up and didnt even try to fix it

5 Likes

same, i tried using objectcache too and it didnt work that well so i made my own instead

Just found this out recently but roblox just completely stops rendering parts in the workspace if theyre far enough away from the player. Meaning that if a part is far enough it will just return as nil in the workspace (though i believe this is only on the client). Ive had this problem with both ObjectCache and PartCache for a while where they would just randomly return nil parts and I think this is probably the issue. Though ObjectCache returns parts just fine sometimes, so its very strange.

1 Like

Doesn’t this just happen because of streaming enabled. Because as soon as the parts are far enough they are parented to nil. Also would explain why this only happens on the client and not the server.

1 Like

This sounds like something caused by instance streaming. Unfortunately, it is not a perfect system to work with yet. But, fortunately, there’s a few ways to fix nil instances. Just turn off StreamingEnabled under Workspace, or, if you prefer to keep it enabled, set every model you know you’ll use with the module to ModelStreamingMode.Persistent. This mode streams the models in and never streams them out.

Hey, I don’t seem to be able to get it to work anymore. Can you help?

How can i use this module in serverside and client side seperately. Basically i want to have 2 seperate hitboxes, one will be replicated to all client and inside server and one hitbox will be only shown to local player. I tried to create 2 seperate MoveableHitboxes one in ServerScriptService and one in StarterPlayerScripts but i got this cache error

“Attempted to return part “Part” (Workspace.VoxelHolder.Part) to the cache, but it’s not in-use! Did you call this on the wrong part?”

What should i do? should i use seperate caches for client and server? if so how can i do that and is vox breaker capable of that.

How do i make it so that the parts that were seperated from the original block get destroyed when the original block regenerates? Right now i can duplicate parts indefinitely by just breaking a part and waiting for it to regenerate

edit: nvm i forgot debris exists lol

If you’re going to use VoxBreaker independently on both the client and server, then you should have 2 instances of VoxBreaker, one on the server, and one on the client. If the cache is created on the server it cannot be accessed by the client, and likewise if you create parts on the client then the cache on the server will not recognize them, as they were instanced on the client. So yes, you’d need two different caches.

1 Like

Hmm so in order to achieve two diffrent caches should i create my own caches with PartCache module? When i look at your code i see you create a cache at the beginning of the code and you use that cache only. How can i use diffrent caches when vox breaker uses the cache it creates at the beginning of the code. Will it work if i were to copy the module to, ServerStorage and use that one for the server and use the ReplicatedStorage one for client side?

Hey, was just wondering if your planning to release an update for this module and if so when? Voxbreaker is life <3

Yes, you will literally need to have two different instances of the module running. Though honestly I don’t recommend using this module on both the client on the server, and it wasn’t designed with that functionality. Ideally, you’d either use the module on the client or the server, not both, and this is due to the reasons stated before. VoxBreaker creates one cache of parts using ObjectCache which can be done on either the server or the client, but when you try to cross reference parts that were made on the client with a cache created on the server, you get into some weird shenanigans where it’s confusing to tell what the cache recognizes and what it does not.

Basically, yes, use two modules, one on the server and one the client. But I doubt this will work too well in terms of visual results since the module wasn’t designed to work like that.

1 Like

I’ve been working on it on and off whenever I have some free time. Like I’ve said before I’m busy with a pretty big game I’m working on with a pretty big team, and college as well. I’m currently just stuck on figuring out greedy meshing. The problem is that most greedy meshers I can find only work for specific requirements like all parts being equal sizes, and generally have different conditions for merging parts that don’t really fit either of the algorithms I’m currently using with VoxBreaker. As soon as I can figure this out I guarantee you the update would be out super fast.

5 Likes

I keep getting an error : Part is not a valid member of part Workspace.part when I try to weld the hitbox to something

send code characterlimitttttttt