Search Unity

[RELEASED] RayFire for Unity. Runtime demolition and fragmentation plugin.

Discussion in 'Assets and Asset Store' started by Mir-vadim, May 8, 2019.

  1. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Of course you can, but there is one important step you should do before creating prefab.
    After you fragment your object using Shatter you should Export fragments meshes into asset file using button at the bottom of Shatter. After this all fragments meshes will reference to this asset meshes, then you can crate prefab.
    Without this step you will loose meshes in prefab because after fragmentation all meshes stored in scene and prefab won't be able to reference to them.
     
  2. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Sorry, there is no built-in functionality for such effects. But I will think about this.
     
  3. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Yes, I already made some tests and they were not as good as I expected. Mostly because I do not have a lot of heavy math methods, most of the code is component management which can not be moved in Job System and those math functions I have is not big enough to compensate time and memory I spend to pack everything in NativeArray and unpack data back to usable format after calculations.
    I need to rewrite them completely from scratch to avoid this step so they will be ready to be used with Job without all these extra steps.
    I will consider this for all new features I am going to add later and I guess at some point later I will rewrite existing code to make it more friendly for Job System.
     
  4. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    1. I will add some DemolishAll () method which will check if there are other Rigid components in Nested Cluster and demolish them as well. But you can do this for now by getting all fragments in demolished Rigid .framgents list and init demolition in your code for now.
    2. It is supported, only runtime mesh slicing/fragmentation not supported because it needs dlls which we need to compile for consoles.
    3. Of course you can post your code if you want.
     
  5. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    I saw that this asset is on sale in the Asset Store.... It's such a cool asset! I'm developing with DOTS so I can't buy it right now -- Any developments in the DOTS/ECS/Jobs side of things?
     
  6. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Sorry, there is no special support for DOTS for now. I tried recently to rewrite some parts of code with Job support, but since most of the plugin work is management of components (not heavy math) there was not any noticeable difference in performance.
     
    atomicjoe likes this.
  7. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    Thanks for the reply. Is there any chance that it could at least be tweaked so that it could work without game-objects and monobehaviours even if it's not more performant? In a DOTS game where everything exists as entities, it is difficult and hacky to have to create, synchronize, and manage the lifetimes of temporary and/or unnecessary game objects that don't really do anything other than function as hacks to implement something that hasn't been implemented in ECS yet.
     
    Last edited: May 14, 2023
  8. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Yeah, this is why there was not more performant with Jobs support, I had to convert all necessary data to NativeArrays and back to usable data. But you can of course try to edit code to use Jobs where you think it will work better. If you want I can send you full package to try it and check code, Sale just started, so you will have some time to decided if it is worth to buy.
     
  9. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    I'm probably not doing a good job of explaining what I'm getting at. Looking at the demo video, I can see that a Monobehaviour component is added to a game-object called "RayfireRigid" and it has functions for RaycastRigid, Demolish, Activate, Fade, etc. In ECS if that gameobject was placed in a subscene, the entire RayFireRigid component and associated game-object would just disappear after pressing play and a useless empty entity would take its place. To be useful, I would need a Baker to convert that monobehaviour into an ECS component, but I have no idea how to do that or if it's even possible.

    The only alternative I can think of would be to keep all the destructible items as game-objects, however, they would be incompatible with everything else in the scene it's all represented as Entities instead of GameObjects.
     
  10. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Well, then I guess you can't use it for now, I basically need to completely rewrite whole Rigid component (and other components) logic, having only Bakers will not be enough.
     
    lclemens likes this.
  11. unity_D823CE9B3E96D6748393

    unity_D823CE9B3E96D6748393

    Joined:
    Nov 16, 2022
    Posts:
    6
    Hi @Mir-vadim! Can this asset be used for a case.. where the part of a terrain is removed when a sphere collides with it? Kind of worms like destructible terrain but in 3d? The terrain is one mesh piece
     
  12. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Hi, sorry, but no, there is no such support for now.
     
  13. unity_D823CE9B3E96D6748393

    unity_D823CE9B3E96D6748393

    Joined:
    Nov 16, 2022
    Posts:
    6
    Thanks! Is it possible that one part of mesh remains static and other dynamic when a collision occurs so it gives the effect of falling down? And all this needs to be dynamically at runtime

    Basically my use case is, There is a single mesh(dynamically generated) on which the player stands and shoots, the mesh should be destructible

    And lastly, does the plugin support shapes which have mesh collider with Convex unchecked? Basically non-convex shapes?
     
    Last edited: May 30, 2023
  14. AbelSierra

    AbelSierra

    Joined:
    Jul 19, 2018
    Posts:
    19
    Hello! I am having problems trying to make work dynamic batching with the shattered pieces, it just does not batch a single thing... Is it something supported?
     
  15. unity_D823CE9B3E96D6748393

    unity_D823CE9B3E96D6748393

    Joined:
    Nov 16, 2022
    Posts:
    6
    Another question, is it possible to pre-process a concave mesh and break it into pieces using your asset and then use nested clusters on it? Like in the video below, the ring already has pieces in the FBX model

     
  16. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Hi, dynamic batching should work, can you contact with me in discord about this issue, so we will figure out why it doesn't work for you.
     
  17. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    it should use already applied colliders, doesn't it work in this way for you? and again, please, contact with me in discord to get support, sometimes I do not get notifications when someone post here new message.
     
  18. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    101
    I would like to know if this tool is capable of fragmenting non-readable meshes (which don't have the Read/Write setting)? Not at runtime, but at least in the editor?
     
  19. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    No, this is one of the most frequent issue for a lot of users, they forget to make mesh readable.
    But I never tried to make it possible to fragment not readable meshes, I will make some research about this later.
     
    DrSeltsam likes this.
  20. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    101
    Thanks @Mir-vadim , sounds good! :) It's understandable to require readable meshes at runtime, but in editor, the workflow would be a lot smoother if there was no need for readable meshes (I have lots of meshes and would like to create fragmented versions of them, not at runtime, only in the editor).
     
    zalogic likes this.
  21. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    I also agree with @DrSeltsam.
    Editor only workflow should not affect runtime optimizations decisions and runtime usage restrictions should only apply to runtime API usage only. ✌
     
  22. zalogic

    zalogic

    Joined:
    Oct 6, 2010
    Posts:
    273
    This should be doable by "wrapping" the API runtime methods used into a separate editor-only workflow tool / API that could automatically apply the required readable meshes flag (and cache the previous state of course) until the edit happens and then re-apply the previous state if necessary.
    Does this help?
     
  23. animal531

    animal531

    Joined:
    Aug 26, 2014
    Posts:
    25
    Does Rayfire use the new advanced mesh API to construct meshes, or still the old way?
     
  24. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    25
    Good question!
     
  25. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Hi, for now we do not use it since we started develop it for Unity 2017 and Advanced Mesh API was added in 2021 if I am not wrong. But at this moment we are rewriting from scratch whole fragmentation engine for maximum efficiency in Unity so we will take Advanced Mesh API into account.
     
    Last edited: Sep 14, 2023
    AthrunVLokiz likes this.
  26. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    25
    Wow! That's awesome news!
    Do you have a general idea of when you'll want to release the update / new asset?
     
    Last edited: Sep 18, 2023
  27. Blackghost

    Blackghost

    Joined:
    Oct 2, 2012
    Posts:
    111
    Good Morning. Im trying to get Rayfire to work with Third Person Cover Shooter template. Ive looked at numerous videos, followed the document, but still cannot get it to work. Im using Unity 2022.123f. The videos all arent cohesive. What are the steps to get my projectiles and object destruction working?
     
  28. NickNack84

    NickNack84

    Joined:
    Dec 5, 2013
    Posts:
    6
    Hi, I've updated Rayfire to the latest version 1.60. (clean install: all files removed and reinstalled)
    It seems that there is a bug with the fragmentation count. Amount and Variation is set to 1 or 2 but I always get about 50 meshes.
    If you just add RayfireShatter to a mesh with Amount of 1, click the "Fragment" button in the editor and you get 48 meshes. Can you please check this / help us?
    ---
    We found the issue but no solution: It is due to the self-enclosed mesh areas. (not connected points) They are treated as separate meshes, although there is only one mesh object. This was not the case in the last plugin versions. Is there a way to treat these separated mesh faces as one again?
     
    Last edited: Oct 11, 2023
  29. DimNik97

    DimNik97

    Joined:
    Oct 19, 2022
    Posts:
    11
    Hello, i am facing a problem when trying to build my game on Linux Dedicated Server, i get some errors like
     The type or namespace name 'DotNet' does not exist in the namespace 'RayFire' (are you missing an assembly reference?)
    The type or namespace name 'RFShatter' could not be found (are you missing a using directive or an assembly reference?)


    I guess that dedicated server build is not supported? Is there anything i can do?
    Thank you and congratulations for the amazing work.
     
  30. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    Hi, which plugin build do you use?
    Also, can you contact with me in Discord?
    https://discord.gg/8G98JKj
     
  31. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Hello there so after searching here and no luck decided to post my issue.
    I am using RigidRoot with Connectivity, and when Resetting all the fragments rotations are now wrong. Any advice? Thanks!
     
  32. Mir-vadim

    Mir-vadim

    Joined:
    Apr 18, 2017
    Posts:
    256
    I fixed this bug in my current wip build. I will try to release new build tomorrow. Let me know if you will have this problem after updating plugin.
     
  33. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Thank you!
    *Edit - Fixed the issue with setting the Timescale to 0, is to not set the FixedTimeScale to 0 also. only the regular Timescale, then pausing and unpausing doesn't make the physics flicker.

    Original: One other issue I had for a while is when I pause my game I set the TimeScale and FixedTimeScale to 0. And then, when unpausing the Activated fragments are thrown upwards, making the demolishable explode or self demolish by pausing and unpausing the game.
     
    Last edited: Jan 16, 2024
  34. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    437
    hi there @Mir-vadim,
    thanks for this amazing plugin. I am using it mostly to create a reference demolition in the editor and then trigger it in playmode. This is working really well.

    But I have a small issue regarding performance. I have a barrel prefab with child objects (renderers), but it is quite low poly (around 2k vertices).

    The problem arises when I try to slice the model, so I am doing something like this:

    Code (csharp):
    1.  
    2. foreach (var targetRenderer in targetRenderers)
    3. {
    4.     var rayfireRigid = targetRenderer.gameObject.GetOrAddComponent<RayfireRigid>();
    5.     rayfireRigid.Activate();
    6.     rayfireRigid.AddSlicePlane(new []{ slicePosition, sliceNormal});
    7.     rayfireRigid.Slice();
    8. }
    9.  
    But there is a severe frame drop, around 2MB of garbage is created and the CPU takes almost 1s to perform the slice. Is this expected or am I doing something awfully wrong? I've tried various demolishionType(s) like Runtime, Awake Precache and so on, but the behaviour is more or less the same.

    I am running windows, editor 2022.3.17f1 and rayfire 1.64 from the asset store. My system spec is: i9 10940X, 3080 Ti, 64GB DDR4.

    This is the editor profiler: