Is it possible to have a dynamic mesh collider on voxel objects?

0
cheesebugur101 posted this 25 September 2017

As part of the volume gets destroyed, I would like what's underneath to be accessible to ray casting. Right now I'm able to destroy the outermost layer of voxels, but as soon as those are gone, the mesh collider doesn't allow for the exploder's raycast to reach the voxels in behind.

I'm also wondering how volume splitting was done (https://www.youtube.com/watch?v=1jr37Wj6S6s), and if it's possible to smash a volume into smaller volumes.

Any help is appreciated!

1 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 26 September 2017

I'm guessing you're using Convex mode for the meshcolliders. Concave would be the mode to use if you want the collision mesh to exactly match the voxels. However, concave meshcolliders come with restrictions, such as not playing nicely with rigidbodies. They work fine for (for example) terrain or anything that doesn't move.

If you need to use convex, then your best bet would be to use a hybrid raycast. You would first cast a ray using normal Unity physics and then when you hit a Volume object, continue stepping along the ray using Picavoxel's Volume.GetVoxelAtWorldPosition() until you either hit a voxel or reach a certain distance to stop checking.

There is an example of this in the Islands demo, take a look at the IslandsClickBoom.cs script.

The volume splitting was just an experiment and isn't part of the main PicaVoxel package because it's probably not performant enough to use in production games. Your mileage may vary, though, so feel free to give it a try: https://1drv.ms/u/s!AhdchalVsPvXnMk861F6BPKYeCbr0w

One thing it doesn't do which it probably should is destroy splits when there are no voxels left active, which would require a count of active voxels after a split takes place.


Our 103 members have posted 431 times in 104 discussions