Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Released] Voxel Destruction

Discussion in 'Assets and Asset Store' started by Atangames, Apr 29, 2023.

  1. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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: ✔️
    Linux: ✔️ Tested on Ubuntu and Fedora, should work on most distros
    Android: ✔️ Note: Streaming Assets don't work as expected on aab files, but it works fine with apk
    WebGL: ✔️ Uses Webrequests to read Streaming Assets
    VR: ❔ Worked on a Oculus quest 1, but I can't guarantee that it works on all headsets.
    MacOS and IOS: ❓ 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.
     
  2. StCost

    StCost

    Joined:
    Mar 1, 2017
    Posts:
    25
    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
     
  3. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
  4. mugundan-animator

    mugundan-animator

    Joined:
    Nov 29, 2017
    Posts:
    1
    How this collapsing system works?
     
  5. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
    Stormer2020 likes this.
  6. unity_3755162BF7B60DBDA3C1

    unity_3755162BF7B60DBDA3C1

    Joined:
    Apr 18, 2022
    Posts:
    3
    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?
     
  7. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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!
     
  8. unity_2E34E38A63FC37AD9428

    unity_2E34E38A63FC37AD9428

    Joined:
    Dec 23, 2021
    Posts:
    1
    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?
     
    Last edited: Jul 11, 2023
  9. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
  10. unity_3755162BF7B60DBDA3C1

    unity_3755162BF7B60DBDA3C1

    Joined:
    Apr 18, 2022
    Posts:
    3
    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.'.
     
  11. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
  12. unity_3755162BF7B60DBDA3C1

    unity_3755162BF7B60DBDA3C1

    Joined:
    Apr 18, 2022
    Posts:
    3
  13. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
  14. andreymixler

    andreymixler

    Joined:
    Nov 25, 2022
    Posts:
    2
    Hello i have a problem.
    If I put "Build all childs", then all my objects appear in one chunk.
    Help me please ^^ upload_2023-7-27_14-14-48.png
     
  15. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
  16. basil3

    basil3

    Joined:
    Dec 3, 2015
    Posts:
    29
    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
     
  17. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
    basil3 likes this.
  18. Amitos

    Amitos

    Joined:
    Feb 13, 2021
    Posts:
    1
    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 picture image.png
     
  19. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    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.
     
  20. ILYICHZC

    ILYICHZC

    Joined:
    Apr 28, 2017
    Posts:
    1
    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?
     
  21. Atangames

    Atangames

    Joined:
    Sep 16, 2020
    Posts:
    16
    Hi, as long as the buildings do not have a convex mesh collider it should still be possible to enter them. Make sure that "start with physics" and "use convex collider" are disabled. You can also turn of collapsing since that can also trigger activation of physics.