[Released] Voxel Destruction

Hi,

This is the forum for the package “Voxel Destruction”.

You can find it here: Asset Store

The ultimate tool for creating immersive and realistic destruction effects in your Unity games! With voxel-based physics and a user-friendly interface, Voxel Destruction allows you to create detailed destruction effects that will leave players amazed. Whether you’re creating a shooter, a survival game, or an action-adventure game, Voxel Destruction provides the features and tools you need to take your game to the next level. With support for large-scale destruction, destructible terrain, and dynamic objects, Voxel Destruction makes it easy to create immersive, interactive environments that players will love.

→ Directly load from MagicaVoxels .vox files:
This Package allows you to model anything in the free Voxel Modeling Software “MagicaVoxel” and then save it in the StreamingAssets folder and directly load them in Unity.

→ Supported Platforms:
Windows: :heavy_check_mark:
Linux: :heavy_check_mark: Tested on Ubuntu and Fedora, should work on most distros
Android: :heavy_check_mark: Note: Streaming Assets don’t work as expected on aab files, but it works fine with apk
WebGL: :heavy_check_mark: Uses Webrequests to read Streaming Assets
VR: :grey_question: Worked on a Oculus quest 1, but I can’t guarantee that it works on all headsets.
MacOS and IOS: :question: Not tested, I can’t guarantee that it works

→ Greedy Meshing:
It is using a fast Greedy Meshing algorithm that combines neighbor faces together to save processing power.

→ Collapsing:
The package automatically detects voxel groups that are no longer connected to the main voxel object and separates them into a fragment.

→ Performance:
The Package is using the Unity Job system to make the Greedy Meshing calculations multithreaded, you can choose between a simple Job a ForJob and a ParallelForJob.

Looks great

Does it have some kind of LODs? Would be great to use it in procedural infinite world
Also if there would be an option to smooth out the blocky voxels - I’d be glad to buy the asset

Hi,

No the package does not have any LOD system and does not support procedural world generation.
However, it would be possible to use the package to build a world generation system, but it would require a lot of changes in the code.

How this collapsing system works?

Hi,
the collapsing system is a job that runs in the background after a destruction occurred. It calculates all pieces that are not connected to each other and separates all except the largest piece.

1 Like

I have a prefab containing about 100 voxel objects, when I press a button I will instantiate this prefab, the problem is it takes a lot of time to instantiate. About 1 minute.
Can I speed it up faster?

I think the best way would be to minimize the count of voxel objects, but it depends on what you are using it for. Try to merge some of these objects in magicavoxel, you can put them on another layer so they get drawn separately.

“Precalculated fragments” is the fastest destruction type, but it also takes the longest to load, maybe consider using normal fragmentation on some smaller voxel objects. Finally for very small objects you could consider just using normal prefabs, instead of destruction.

Hope that helps!

Atangames Hello! I have a problem with destruction. When the object is on the stage, there are no problems with destruction. But when the object appears after the “Instantiate” method, the object is not destroyed, or is not destroyed correctly. The problem occurs more often on android devices. How to spawn correctly?

Hi,
Instantiating the object should not be a problem, maybe the problem is caused by the script that creates the destruction. Make sure to use GetComponentInParent and GetComponentInChildren when checking for voxel objects.

If this does not solve your issue, please enable “debug” on your voxel object and send me some more info on what is happening.

Somtime a got this errror and voxel object can’t be destroy anymore :

ObjectDisposedException: Cannot access a disposed object.
Object name: ‘The NativeArray is already disposed.’.

Hi, could you please send me the exact error with stacktrace and a screenshot of you voxel object settings. It would help me to understand what is causing the problem.

Hi,

I submitted an update that should fix the issue, it still needs to go through the unity verification process and should be life in a few days.

Hello i have a problem.
If I put “Build all childs”, then all my objects appear in one chunk.
Help me please ^^

Hi, the package is not able to get the global position you placed voxel objects on. You will need to disable build all childs and creating a voxel object for each object in your vox file.

Hi,

Just purchased the asset and I’ve been playing around in Magicavoxel and exporting some test objects to work out the best workflow for my use case and have had a bit of trouble with the asset being able to read the .vox files.

Essentially, the ‘export’ function (selecting .vox) in Magicavoxel saves the file as a .vox file but this doesn’t seem to be able to be read by the Voxel Object script when trying to build the mesh.

If I use ‘Save project as’ in Magicavoxel this again creates a .vox file and this can be read by the Voxel Object script and the mesh builds fine.

Perhaps I am missing something completely!!

For context, I would like to create my entire model within Magicavoxel made up of separate objects and then bring that into Unity and apply destruction to just certain parts of the model.

My idea is to have a root gameobject that is my ‘model’ in Unity and have children which make up each part of the model. Each child would be an individual gameobject with it’s own Voxel Object script and referencing it’s own separate .vox file for that part (that way I can control destruction on a per part basis).

I thought I could easily achieve this by having one master project in Magicavoxel and then exporting each individual selection as a separate .vox file but that function produces a file that does not seem to be able to be read by the Voxel Object script. For now I have to do the above and then open the file and save as to overwrite it and then it works.

If you need any further information let me know.

B

Hi,

You should always use the direct “.vox” files and not export them as a seperate “.vox”. This should make things easier for you since you can just import your vox files into unity and to make changes just open it using magicavoxel, edit them and safe the changes. No need for reimporting.

The workflow you are talking about should be easily achievable using the package. You can use the main vox file you have, assign it to a voxelobject, disable “build all childs” and select the index of the layer. You can then do this and create voxel objects for every layer in the vox file you desire.

I hope that I was able to help you, there also is a setup video on the assetstore page that should help with problems like this.

1 Like

Hello, I’m wondering if it’s possible to recreate the voxel slicing feature from the game “Clone Drone In The Danger Zone” using this asset. If so, could you explain how to do it?

In that game the player is able to slice off voxels from models using a sword as seen in the picture9255252--1294497--image.png

Hi,
The package does not really have a slicing feature, but it would be possible to develope one yourself. The package would only help you building a mesh out of VoxelData, so you will have to write all the slicing logic yourself. Keep in mind that the package is not designed for usecases like this and you will need to rewrite a lot of code.

Hi. In your demo game it’s possible to get into buildings using wholes of destruction. Also it’s possible to throw weapons inside. But in your demo scene in Unity editor, buildings have mesh colliders which prevents to go or throw something inside. What do I need to set up in the scene to have same ability?