Introduction
Hello, I made this cool module that allows you to make holes in parts but with voxels . It is basically a voxelizer that can handle lots of voxels in your destruction game, or if you just need voxels for an explosion.
This module uses octree division and also greedy meshing and ObjectCache for ultimate performance. It works for hundreds of holes in your game before you even start lagging a bit. It also provides some useful functions that will help you with your needs, such as it can cleanup voxels in the world if you are doing a map reset. It stores a lot of the parts before hand, then moves them in when needed which provides the trick of instancing new parts, while itās not.
Example
Here is an example of a AK-47 and a AK-47 Shotgun (yes), that can create holes in parts. As you can see, you can adjust the voxel size for different types of weapons.
I have adjusted the voxel size to be pretty small here.
The script itself isnāt too complicated. Thought it does have many features! You can adjust multiple things such as voxel size, debris amount, ignore lists and more. Currently, it does not support square hitboxes, or wedges.
The module comes in the name of āVoxManagerā, which will handle most of the creation for you. If you need a lot of customizing, you can call Voxelizer.subtractHitbox
yourself in the Voxelizer module located under the main script.
Any feedback would be appreciated, and I will try to add more to this. Right now, I feel it is pretty easy to add your own new stuff to it, such as breaking sounds and changing debris sizes and other things.
Downloads:
Module: https://create.roblox.com/store/asset/90280745196148/VoxManager
API
VoxManager:voxelize(hitbox, minimumVoxelSize, finalVoxelSize, randomColor, debris, debrisAmount, ignore)
Info:
Pass in a sphereical part, and anything itās touching it will destroy and become voxels.Parameters:
Hitbox - A part of type Enum.PartType.Ball
MinimumVoxelSize - A number, the minimum voxel size. 2 is recommended.
FinalVoxelSize - A number, when the calculations are done, voxels will try to go to this size. Recommend this should be the same as MinimumVoxelSize .
RandomColor - A boolean, debug coloring, shows the divisions on the part.
Debris - A boolean, whether there should be debris.
DebrisAmount - A number, the amount of debris per subtraction.
Ignore - A table of parts to ignore in the hitbox calculation.
VoxManager:voxelizePosition(position, radius, minimumVoxelSize, finalVoxelSize, randomColor, debris, debrisAmount, ignore)
Info:
Pass in a position and radius, and anything in that area will be destroyed and become voxels.Parameters:
Position - A Vector3, where the subtraction will take place.
Radius - A number, the radius of the subtraction hitbox.
MinimumVoxelSize - A number, the minimum voxel size. 2 is recommended.
FinalVoxelSize - A number, when the calculations are done, voxels will try to go to this size. Recommend this should be the same as MinimumVoxelSize .
RandomColor - A boolean, debug coloring, shows the divisions on the part.
Debris - A boolean, whether there should be debris.
DebrisAmount - A number, the amount of debris per subtraction.
Ignore - A table of parts to ignore in the hitbox calculation.
VoxManager:cleanup()
Info:
Cleans up all voxels in the world.
VoxManager:setDebrisSize(multiplier)
Info:
Sets the debris size, relative to the destroyed part hole. Recommend 0 - 1.Parameters
Multiplier - A number, the size relative to the destroyed part.
Are you thinking of ever using this?
- Yes
- No
- Iāll definitely use it later for other projects.
0 voters