Search Unity

Ultimate Fracturing Destruction editor extension for Unity 3D

Discussion in 'Assets and Asset Store' started by UGTools, May 30, 2013.

  1. stperona

    stperona

    Joined:
    Sep 14, 2016
    Posts:
    2
    @davidchaseling As a quick and dirty solution I modified the FracturedChunk.cs file (Ultimate Game Tools/Fracturing/Scripts/FracturedChunk.cs) OnCollisionEnter and OnTriggerEnter functions to get the velocity from a utility controller script if it was present:

    Code (CSharp):
    1. void OnCollisionEnter(Collision collision)
    2.     {
    3.         if(collision.contacts == null)
    4.         {
    5.             return;
    6.         }
    7.         if(collision.contacts.Length == 0)
    8.         {
    9.             return;
    10.         }
    11.      
    12.         Vector3 collisionVelocity = Vector3.zero;
    13.         // Get SteamVR velocity.
    14.         ControllerUtils steamVRControllerUtil = collision.collider.gameObject.GetComponentInParent<ControllerUtils>();
    15.         if (steamVRControllerUtil) {
    16.             collisionVelocity = steamVRControllerUtil.GetVelocity();
    17.         } else {
    18.             collisionVelocity = collision.relativeVelocity;
    19.         }
    20.         HandleCollision(collision.collider, collision.contacts[0].point, collisionVelocity.magnitude);
    21.     }
    22.     void OnTriggerEnter(Collider other)
    23.     {
    24.         if(FracturedObjectSource == null || other == null)
    25.         {
    26.             return;
    27.         }
    28.         Rigidbody otherRigidbody = other.attachedRigidbody;
    29.         Vector3 collisionVelocity = Vector3.zero;
    30.  
    31.         // Get SteamVR velocity.
    32.         ControllerUtils steamVRControllerUtil = other.gameObject.GetComponent<ControllerUtils>();
    33.         if (steamVRControllerUtil) {
    34.             collisionVelocity = steamVRControllerUtil.GetVelocity();
    35.         } else {
    36.             collisionVelocity = otherRigidbody.velocity;
    37.         }
    38.         HandleCollision(other, other.transform.position, collisionVelocity.magnitude);
    39.     }
    Here's the utility script that shows how to actually obtain the velocity:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ControllerUtils : MonoBehaviour {
    5.  
    6.     private SteamVR_TrackedObject trackedController;
    7.     private SteamVR_Controller.Device controllerDevice;
    8.     private uint controllerIndex;
    9.  
    10.     void Awake() {
    11.         trackedController = GetComponent<SteamVR_TrackedObject>();
    12.     }
    13.  
    14.     // Use this for initialization
    15.     void Start() {
    16.         controllerIndex = (uint)trackedController.index;
    17.         controllerDevice = SteamVR_Controller.Input((int)controllerIndex);
    18.     }
    19.  
    20.     public Vector3 GetVelocity() {
    21.         Transform origin = trackedController.origin ? trackedController.origin : trackedController.transform.parent;
    22.         Vector4 velocity;
    23.  
    24.         if (origin != null) {
    25.             velocity = origin.TransformVector(controllerDevice.velocity);
    26.         } else {
    27.             velocity = controllerDevice.velocity;
    28.         }
    29.  
    30.         return velocity;
    31.     }
    32.  
    33.     public Vector3 GetAngularVelocity() {
    34.         Transform origin = trackedController.origin ? trackedController.origin : trackedController.transform.parent;
    35.         Vector4 angularVelocity;
    36.  
    37.         if (origin != null) {
    38.             angularVelocity = origin.TransformVector(controllerDevice.angularVelocity);
    39.         } else {
    40.             angularVelocity = controllerDevice.angularVelocity;
    41.         }
    42.  
    43.         return angularVelocity;
    44.     }
    45. }
    This is pretty rough though and an ideal solution would be something that doesn't require a component lookup on each detection.
     
  2. davidchaseling

    davidchaseling

    Joined:
    Apr 20, 2015
    Posts:
    8
    Thanks for that @stperona. Really appreciate it! The solution you have is far better than what I was going for. Initially I thought I would have to calculate velocity the old fashion way (distance travelled/time), which may have required storing the last frames position to use as a reference. I am finding that using this asset with VR is prone to some lag but with some fiddling and non-excessive use I think it can be managed.

    Thanks again. If I find a better solution I will be sure to post it here.
     
  3. dre4mer

    dre4mer

    Joined:
    May 26, 2016
    Posts:
    7
    Hi there, i'd like to purchase this but I can't quite tell if it can work for my application. I'm instantiating many instances of a prefab which would then be floating. Can that single prefab just be pre sliced at all levels of LOD and exploded as needed?
     
  4. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    Does this allow cut a tree in any angle by a weapon?
     
  5. aaron2005

    aaron2005

    Joined:
    Mar 22, 2014
    Posts:
    3
    Hi there. I try a combination of this fracture and the chronos time manipulation. So, I destroy an object and then I revert this action, until the object is fixed again. I am able to add the chronos script to the chunks to let the pieces move forward and backward. But I have no idea, how to connect a chunk to the other again while the game plays?

    Hope Youtubelinks are allowed to show a little preview.


    I start with a fracture-explosion I do by raycast. That destroys the connection and the ceiling fall. With the timetool I revert the time, so the ceiling will be on its origin place. Now I need to connect them again, to not fall down after play normal time agein. Someone an idea or a hint?
     
    red2blue likes this.
  6. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    I think you might have to add the scripts to the prefab as well as the chunks -how else would chronos know to undo/revert the trigger of of the prefab. I think you would definitely have to tell it to revert the main exploding prefab.
    I'm guessing here that chronos should remember all game states that are tagged and put everything back tagged/scripted where it belongs so the main prefab should be tagged too. The other thing you might try if everything else is exhausted is an real-time object replacement tool or if you're using World Streamer I've recently put in a request for a script that can follow a moving object and replace that object by proximity so imagine if the last block to reverse came back to start then it would trigger to replace/reset the prefab. Maybe there are better methods but these come to mind for now. Then again maybe you could request some object replacement tool script from the chronos developer when time resets back to 0

    I would work in a new test scene

     
  7. maxaud

    maxaud

    Joined:
    Feb 12, 2016
    Posts:
    177
    Curious, most of the demos I see are whole meshes being deconstructed. Is there a way to simply punch a hole through a mesh?
     
  8. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    Yes with fists maybe with just a collider but you might have to change the physical object strength also you may have to add the explosion script to your fists, just knock the explosion strength down.
     
    Last edited: Nov 1, 2016
  9. maxaud

    maxaud

    Joined:
    Feb 12, 2016
    Posts:
    177
    I would to have it work with raycasting and have it just pop a hole where the cursor clicks essentially.
     
  10. aaron2005

    aaron2005

    Joined:
    Mar 22, 2014
    Posts:
    3
    Thanks for the tips. I put everything related to the destruction to this chronos. But without any progress.
    I tried to collect the adjacency datas of a chunk and connect them again. But it doesnt work. I also tried to connect them manual together.
    I don't really know, how they "stick" together.
    The Chronos also seems to use trigger, like the fracture.
    I also thought, they would save the whole state. But it seems that they more or less create the physical stuff? World Streamer never heard off. I thinking of a way to deactivate the timeflow if the chunks are there, where they are at the beginning. Its just kinda frustrating.
     
  11. Arkaid

    Arkaid

    Joined:
    Apr 5, 2014
    Posts:
    4
    Voronoi splitting crashes Unity

    I can't really pinpoint the reason. With some meshes (not all of them), trying to fracture with Voronoi causes the Unity to crash. Specifically SpaceTree.BuildSpaceTree enters an infinite loop, eating all of the available memory until crash. The "queueNodes" queue keeps on growing, never clearing up, adding nodes over and over again until crashing.

    I don't know how to fix it, either the code or the mesh, to keep it from happening.
     
    jeffcrouse likes this.
  12. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Can someone please give me an indication on how it is on batches...and if it can be optimized.
     
  13. Ankaman

    Ankaman

    Joined:
    Feb 14, 2014
    Posts:
    37
    Does it work in 2D Or Sprites with polygon collider too?
     
  14. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    At this point I don't know if the developer is still alive! Tried contacting him via email since his foot injury and he hasn't replied to anyone on the forum here I think maybe for a month. I've known people to pass away from blood clots from broken ankles.
     
  15. BigScary

    BigScary

    Joined:
    Jun 4, 2014
    Posts:
    7
    Hey quick question - I see there's an option to have a method called on a game object when a chunk detaches. Does the caller pass the callee an instance reference for the newly detached chunk? I want to for example ensure my chunks don't have gravity, and have some forces and components applied to them at the moment they detach.
     
  16. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Let's say I have a tornado with physics to pull objects into it and throw them away, could I use this asset to destroy my houses and other objects and then make them pullable by my tornado?
     
  17. im012

    im012

    Joined:
    Oct 4, 2016
    Posts:
    1
    Due to the script of asset my game's CPU usage are much higher in android device...Any Advice..?
     
  18. Deleted User

    Deleted User

    Guest

    When will v2.0 release? I hope you get rid of 3.5.x support (does anyone use that even anymore?) and make it fully use the newest Unity version features etc to simplify this asset and make it better perform.
     
    red2blue likes this.
  19. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    Using the explosion script will allow the destruction to be constant if you like as seen in the video with fracturing in the brick floor from underground..You would attach in the script, a support plane to allow a roof to fall if there is no walls.

    What ever script you want to use (Circular gravity force using attraction) for example could be added as to your mesh to be fractured then when you press fracture that script will be added to all the pieces. They aren't rigid bodies by default and if you make them all rigid body your entire mesh would fall. I Think it's best to have some kind of "enable rigid body by proximity, but with inclusion/exclusion tags" added to the mesh to attach to the explosion script so when you add that to your tornado the parts that need to fly will. Check the doc on the website first to make sure this will work for you.
     
  20. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    So I have objects that explode correctly if placed within the editor. But if I try to instantiate them during runtime (they are prefabs) then they just straight don't work.

    Why? Is there special code not mentioned in the documentation for Instantiating a prefab using FracturedObject?
     
  21. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    There is an option on the component "use as prefab" then it saves the data.. it might work for what you're trying to do..
     
  22. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
  23. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    It did indeed. Thank you.
     
  24. Zrob

    Zrob

    Joined:
    Jan 13, 2017
    Posts:
    9
    Anyone know why when I call CollapseChunks(), all the chunks break apart but the mesh renderer is invisible so you can't see them, while the @-SingleMesh remains? Something similar happens when I call Explode too.
     
  25. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    What I've had to do is delete the mesh generated at the bottom with the @ symbol then select all the fragments and enable render . It might of been that the mesh with the @ was for performance and would be disabled on impact or explosion then disable itself and turned on render of the fragments after the hit/explosion but I don't recall it working that way and I don't know if there is any proper procedure to make it work this way.

    I think it would be a far superior option to have the fragments stream into the game rather than render once you impact/explode the mesh with the @ and that @ mesh gets unloaded.. To speed up loading I'd have a proximity script that can be added to a player or object so the moment a long range projectile is shot at the object, the object loads its fragments.. or maybe that if a player is close by the fragments are streamed in. I'd make this suggestion to the author but there's been no word from him for a long time.
     
    Last edited: Jan 13, 2017
  26. Fourthings

    Fourthings

    Joined:
    Feb 15, 2010
    Posts:
    313
    Can anyone tell me what I'm doing wrong here? I fractured two objects, I set one to start static and the other has a support plane at the base. When I hit Play the non static one just starts to fall apart, and the static one does not interact with colliders at all, they pass straight through. How do I set the object up so it looks seamless until contact with a collider and then starts to fall apart? And is it also possible to have object collide with the object before triggering any destruction?

     
  27. SureSight

    SureSight

    Joined:
    Aug 2, 2013
    Posts:
    65
    I am looking at using Fracturing & Destruction in a destructible city simulation.
    I have two questions:
    1. Do you think this tool is suitable for a city with skyscrapers?
    2. Is it possible to repair/undo the fractured damage and return the model to it's undamaged state?
     
  28. Fourthings

    Fourthings

    Joined:
    Feb 15, 2010
    Posts:
    313
    Is it possible to spawn a fractured object from a prefab?
     
  29. Scott2112

    Scott2112

    Joined:
    Feb 1, 2016
    Posts:
    12
    I'm sure I'm probably missing the obvious but after I explode a wall the chunks fall through the
    terrain. It's not a min, max chunk life issue. The chunks all have colliders and Rigidbodies. The rigidbodies are
    set to is Kinematic but unchecking that makes the chunks fall through the terrain before any impact.
    Any ideas?
     
  30. Scott2112

    Scott2112

    Joined:
    Feb 1, 2016
    Posts:
    12
    Working now.. had to make the Fracture object static.
     
    hopeful likes this.
  31. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    @UGTools Could you please mark ResetChunks as virtual in your next update? I would like to extend that method to preserve the isTrigger flag.
     
  32. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    In watching your video I see a flaw that I'm wondering if it's ever been corrected. At the 2:14 point, the video shows the statue standing on just one leg and when the remaining leg is shot, the body of the statue falls. However, it not only falls, it instantly breaks into pieces. But this shouldn't happen. The remaining body part should fall as a whole chunk.
     
  33. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    It seems like this is another abandoned asset? o_O
     
    silentneedle likes this.
  34. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Too bad I haven't checked that before buying the asset. :(
     
  35. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    I'm interested in picking this up. However, it looks like it has either been abandoned or @UGTools is taking a long break. Is it relatively stable? It's just that this is a major niche asset that has functionality that we really need.
     
  36. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I did try to contact UGTools by email. You should definitely do so before buying.

    I got no response.
     
  37. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    I'm interested in using it for breaking holes in objects, similar to Rainbow Six Siege. It would be nice if someone could clarify if this is possible? Otherwise it's in-house development time :p
     
  38. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I would not normally mention a competitor in this thread, but considering the circumstances ... have you checked out the competition?
     
  39. mseare

    mseare

    Joined:
    Sep 24, 2015
    Posts:
    2
    I am attempting to use the "Enable Prefab Usage" option on my FracturedObject. When I check the box, a dialog prompts me to specify where to save a *.asset file. I choose the "Assets" folder, but no file is saved. As a result, I can't use this FracturedObject as a prefab.

    Has anyone else run into this problem? Does anyone have a solution?

    Note: I'm on a Mac. OS X 10.11.6. I'm using Unity 5.5.1f1.
     
  40. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Yes but it doesn't allow for destruction of a single chunk.
     
  41. Weblox

    Weblox

    Joined:
    Apr 11, 2016
    Posts:
    277
    Hi, has anyone got this up and running with RFPSP ? Any Tipp on how to integrate would be welcome. Does the raycast hit detectection require extra setup or integration scripts? Thanks in advance.
     
  42. Safemilk

    Safemilk

    Joined:
    Dec 14, 2013
    Posts:
    42
    Hey guys, really sorry if this has been covered, but sifting through the 16 pages was getting overwhelming...

    I just bought this asset, and it's pretty rad, but whenever I enable the Support planes, or make it start static, the collision doesn't work at all. I thought it was something I had been doing, so I went into one of the example levels and the same error was occurring. If I let it break on start, all the collision works correctly for all the chunks.

    I am on Unity 5.5.2 f1, and when I imported the asset it definitely needed to do some API update stuff to it, so my theory is something changed in 5.5.2 f1 that is messing up the collision?

    Has anyone else experienced this?

    Thanks!
     
  43. dave_e3ct

    dave_e3ct

    Joined:
    Nov 7, 2016
    Posts:
    12
    Is there anything in the output windows?
    I had something similar when I copied an object containing the fracture object script, and then just dropped a new object on the source model and clicked "compute chunks". The solution was to make a new script each time. Not had time to look into the issue, but did realise that you can make the objects multi-select by simply adding "[CanEditMultipleObjects]" in FracturedObjectEditor.cs just before the class defn as below:
    Code (CSharp):
    1. [CustomEditor(typeof(FracturedObject))]
    2. [CanEditMultipleObjects]
    3. public class FracturedObjectEditor : Editor
     
  44. mseare

    mseare

    Joined:
    Sep 24, 2015
    Posts:
    2
    @dave_e3ct No log statements about this in the output windows unfortunately. However, I think I figured out what I did wrong. I just went through the following steps several times, and it worked properly:
    1. Create a new FracturedObject in your Hierarchy.
    2. Assign your "Source Object" to the Fractured Object script.
    3. I enabled "Start Static"... you may not want or need that.
    4. I assigned a material to "Interior Material".
    5. I clicked the "Enable Prefab Usage" checkbox. The system prompted me to specify where to save the *.asset file. I chose my Assets folder.
    6. Then I clicked the "Compute Chunks" button.
    7. Right after it was done processing and computing the chunks, it saved the *.asset file to the correct location.
    I think the main takeaway here is that the system won't save the *.asset file until it computes chunks.

    Thanks for your input!
     
    dave_e3ct likes this.
  45. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hello guys!

    It's been a loooong time.
    First of all, I owe you all a big apology. Support has been almost non existant for the last 4 months. Since last week I've started getting busy again answering tons of e-mails and trying to get things started.

    Some of you may know that back in July I suffered a full Achilles tendon rupture practicing sports that required surgery and had me immobilized for two months. No big deal, it sucked hard but besides for a couple of weeks it didn't prevent me from working. I was fortunate enough to be able to do my regular job from home and everything was OK.

    However, in mid October it ruptured again in the middle of the healing process. This time I was very unfortunate because a re-rupture is very bad news.
    From this point on everything that could go wrong went wrong. I won't go into too much detail but the rupture was nasty and required an external graft. Surgery this time was very aggressive.
    One of the risks was the surgical wound could reopen and of course it did. I had a nice hole in my leg that led to months of hospital care to avoid an extremely hi risk of infection. A potential infection could cause quite some trouble to say the least :)
    In the meantime my company was trying to finish the game I was working on as lead programmer and all my efforts went to help with the release.
    It is difficult to put into words what I went through but let's just say I went to hell and back. I consider myself an extremely positive and mentally strong person but this really pushed me to the limits. I was drained both physically and mentally.

    Luckily there's some good news after all:
    -Tomorrow I will have my last surgery which should be minor and hopefully be the last one. I have been working my ass off and if everything goes OK I should be fine after summer :)
    -I left my job to be able to spend all my time on personal projects. This means a lot more resources for Ultimate Game Tools from now on, new plugins, updates etc.
    -I can't wait to get back to coding full time again. If everything goes well it should be next week, I miss it so much!

    I'm glad to see you guys again and be back on board. Thanks for supporting my assets and special thanks to everyone that kept the support going, you rock! :)
     
    Lethn, dave_e3ct, red2blue and 5 others like this.
  46. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    @UGTools - Glad to hear you are okay. :)

    Sounds like a rough time.
     
  47. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    I didn't pick up the fracturing tool for fear that it had been abandoned, but now the lack of support makes sense. Kinda feel stupid for not picking it up in the sale :oops: Take your time to get well and don't push yourself.

    Matt
     
  48. Scott2112

    Scott2112

    Joined:
    Feb 1, 2016
    Posts:
    12
    Great to hear you are doing better. That's a tough injury.

    I'm having trouble getting the Fracture wall object to NOT explode when hit by the player but explode when hit
    by a missile. Should this be done with layers? Can you give a brief example?
     
  49. tosvus

    tosvus

    Joined:
    Dec 27, 2016
    Posts:
    44
    @UGTools , I hope you feel better. I have a quick question for you or anyone else reading: This looks great but the visuals in my upcoming game has a very blocky style, so I would like (fairly blocky) objects to break into tiny cubes. Is this possible?
     
  50. KMonkey

    KMonkey

    Joined:
    Nov 12, 2012
    Posts:
    21
    I was trying to get a melee weapon on a NPC to destroy objects on impact but noticed that when the rigidbody of the weapon is animation controlled by a parent object, it ignores all the fractured objects in the scene. I've tried IK and no IK etc... with no luck.

    So I next tried to adapt the Explosion Source script which sort of works but not ideal. I was about to go with this route but noticed that it doesn't correctly trigger connected chunks e.g. directly above and they stay floating. Throwing a rigidbody object at it works fine.

    Any ideas or solutions? or is this intended behaviour?