I've created a simple script which destroys PicaVoxelVolumes one Voxel at a time. Doesn't sound like much but the effect is pretty cool and extremely versatile.
Watch "Ashes in the Wind" in action on Youtube
If someone knows how to embed Youtube vids, please let me know!
Basic Logic - The script loops through all voxels in a volume, based on the Sweep direction and speed. - When a voxel is found, it is deleted (set to Inactive) and a particle is spawned in its place. - The particle is propelled in a direction specified by a Vector3.
The effect was based on the provided Destructor script, but doesn't use raycasting to achieve the effect. I don't know if it's faster but my test scene has 3 objects destroying one voxel each on every tick while maintaining a solid 60fps.
In order to achieve this effect, you need the following 2 functions
1. Note that I've added Voxel.zero to Voxel.cs which simply returns a new Voxel(); i.e. a blank, inactive Voxel.
GetVoxelWorldPosition => This function was graciously provided by Gareth Williams and should be part of 1.2.0. It takes the X,Y,Z voxel coordinates and returns the equivalent world position. Insanely useful!
public Vector3 GetVoxelWorldPosition(int x, int y, int z)
{
Vector3 localPos = (new Vector3(x * ParentVolume.VoxelSize, y * ParentVolume.VoxelSize, z * ParentVolume.VoxelSize) + (Vector3.one * (ParentVolume.VoxelSize / 2f)) );
return transform.TransformPoint(localPos);
}
GetVoxelatXYZ => A bit weird but this function returns a Voxel object from a world position. The functions provided with PicaVoxel only return positions, I needed to access the voxel directly so now we can!
public Voxel GetVoxelatXYZ(int x, int y, int z)
{
Vector3 v = GetVoxelWorldPosition(x, y, z);
Voxel vox = (Voxel)GetVoxelAtWorldPosition(v);
if(vox.Equals(Voxel.zero)) return Voxel.zero;
else return vox;
}
If anyone wants the source to this, let me know!