Search Unity

Ultimate Fracturing Destruction editor extension for Unity 3D

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

  1. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Versión 1.11 is out. Get it now for the latest fixes!
     
  2. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    congrats on new release!

    it was remove the "Call Method Name" from the "Chunk Detach From Object Due To Physics Collision" section in the Events.

    could demo 1 be updated in some future release to include this change that way it dont throw exceptions

    thanks in advance
     
  3. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    It doesn't matter which one gets removed, you need both for the method to be called.
    Yes, it will be updated in the next release.
     
  4. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Hi,
    This asset look fantastic.
    I have a few questions:

    1-Does prefracturing the object add additional complexity to the scene. Like higher polygon count, or materials?
    If yes, how much roughly in percentage?

    2-How are the shards saved? Does it take lots of space.

    I'm considering this assets for mobile, and I've read it works well, so I would like to understand how much overhead it can add.

    3-This is more a personal question. If I make a single model in any 3d apps as composed of separate objects(for example head and body) I can see the seams between the 2 objects unless I weld the vertices. How come there is no seams in your rendering? How do you overcome it?
     
  5. UGTools

    UGTools

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

    1- It does once the object gets broken. Before that it just gets drawn with the same polycount and materials.
    Once it gets broken, then the shards are drawn, and the complexity depends on the number of them you create.

    2-They can be saved along with the scene, or on separate .asset files if you plan to use them as prefabs. They just contain the shard meshes that are saved, no additional information is needed.

    3-Because initially only the single object is rendered. Once the separate chunks get rendered I haven't seen any seems either, only sometimes with per pixel lighted bumpy materials and seeing from a veery large distance.

     
  6. Tu-Dinh

    Tu-Dinh

    Joined:
    Dec 12, 2012
    Posts:
    10
    Hi this asset is fantastic!

    I have a quick question, is there anyway get a callback there is a collision with fractureObject, but didn't cause any detachment ?

    Thanks

    Tu
     
  7. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Not through the tool at the moment :)
    If you need it you can code a script with an OnCollisionEnter notification and then assign it to the all the chunks via multiple selection -> Add Component.

     
  8. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Hi

    First up, great tool. It's bringing a new level of cool to an previously-implemented feature in the game I'm working on :)

    A couple of questions:

    1. I wish to re-use the fractured object repeatedly but still to have them timeout. My first thought was to tweak FracturedObject to include a DestroyRatherThanInactivate bool which affects the behaviour of DieTimer and FO.ResetChunks to SetActive(false) and true respectively. Seem reasonable? (I'd offer a patch if it seems good.)

    2. (Mostly for my Unity gamedev edification) How come DieTimer uses Update() and accumulating Time.deltaTime rather than MonoBehaviour.Invoke() or a Coroutine with WaitForSeconds() ? I was under the impression that MB.I() was most efficient, C.WFS() second and accumulating Update() least (from some UnityAnswers Q with relatively authoritative sounding answerer). Worried I might need to rework code to be better :-\ (I'm relatively new to Unity.)

    Thanks
     
  9. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    My proposal for (1) seems to have basically worked (though I don't claim to have read all of the code and groked all implications! (e.g. 1 time, a null appeared in ListFracturedChunks despite all chunks being present!?)).

    Here's an initial patch for what I have so far (if I manage to reproduce that null, I'll likely need to revise).
    https://gist.github.com/Arakade/8064316

    Let me know any improvements!
    HTH, Rupert.
     
  10. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Iam confused. Can I use any object / Scene? to make it destroyable?
     
  11. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Yes, this is actually a very good idea. I will take a look at the code you provided :)
     
  12. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    There are some minor requirements stated on our website (the object needs to have volume, for instance) but it will work on most objects, yes.
    Your main limitation will be the number of chunks you create and want to simulate.
     
  13. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Hi, I've just purchased this plugin and I've been playing around with it, what I'd like to know is whats the best way to call the functions from java script, thanks.
     
  14. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
  15. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Thanks for the reply, I've tried doing that and I still get the error .. The name 'FracturedObject' does not denote a valid type ('not found').

    Take a look Here
     
  16. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Ok .. found the problem, I'd saved the javascript file in the same folder as the c# scripts and was dragging that into the plugin folder .. O well it's all good fun .. :)
     
  17. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Nice! if you need some help just ask me :)
     
  18. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Great!

    I've improved my change :)

    Version 2 moves the Destroy/Deactivate choice from DieTimer to FracturedChunk which allows it to be called from other paths (including outside the package). An example for clarity, the benefit is that my own "Shot" script that is previously added to all FracturedChunks can simply GetComponent<FracturedChunk>().Destroy(gameObject); and know it'll behave appropriately.

    Happy New Year!
    Rupert.
     
  19. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Ok now I've moved the scripts to the plugin folder I now can't edit the options and now I'm getting this error ..

    Instance of FracturedObjectEditor couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.
     
  20. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Those scripts (the editor ones) need to remain where they are if I'm not mistaken

     
  21. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Ok, I had to move the Editor dir from the Fracturing dir to the Asset\Editor dir and now it works ..

    Think I should have learnt C# .. :)
     
  22. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Got it working :)



    I'll be blowing a lot more up now ..
     
  23. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Nice!! :)

     
  24. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi Rupert,

    I'll definitely look into it when doing the next upgrade. Thanks a lot :)

     
  25. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Hi, I've noticed when I explode an object with sound samples that One Shot Audio GameObjects are instantiated for each sample I've added, what I'd like to know is how do I set the audio properties on these instantiated One Shot Audio GameObjects? As the samples I've added are 3D, and the audio setting for 3D are incorrectly set for my needs, I need to set the volume rolloff and the maximum distance.

    Thanks.
     
  26. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi Griffo!

    Sorry for the late reply, busy holidays :)
    I think I will update the way I trigger sounds with what you can see here:
    http://answers.unity3d.com/questions/316575/adjust-properties-of-audiosource-created-with-play.html
    So that everybody can change sound properties if needed.

    Currently sounds are triggered in line 722 of FracturedObject.cs. If you have some basic scripting experience you can change it in just a matter of seconds, otherwise just drop me an e-mail and I'll do it for you.

     
  27. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Thanks for the reply, I just added an audio source to each fractured piece and gave each one a different rock sound and set the 3D properties to my needs.

    But it would be nice to be able to set the 3D properties in the inspector ..
     
  28. fredr92

    fredr92

    Joined:
    Jul 8, 2013
    Posts:
    292
    Hi im using this package, its real cool and easy too set up but i have run in to 1 problems maybe you can help me out.
    Objects can only be destroyed by explosions, or Objects. how can i do so that raycast guns can destroy gameobjects?
     
  29. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi Fred,

    You can do it easily with a couple of lines of scripting. When you shoot an object you need to check first with a raycast if it hit a destructible object, and if it did just call a single method that will handle all physics/particles/sounds for you:

    Code (csharp):
    1.  
    2. // This will contain the raycast hit information:
    3. RayCastHit hitInfo;
    4.  
    5. // Check if we hit something right after the shot (We use the static method from FracturedChunk)
    6. FracturedChunk chunkHit = FracturedChunk.ChunkRaycast(v3GunPos, v3GunDir, out hitInfo);
    7.  
    8. if(chunkHit != null)
    9. {
    10.     // We hit a fracturable object. Create an impact on the chunk we hit (We call a method on the chunk):
    11.     chunkHit.Impact(hitInfo.point, ExplosionForce, ExplosionRadius, false);
    12. }
    The last parameter of Impact() tells if the explosion also affects free non-detached chunks (true) or not (false).

    Hope that helps!

     
  30. franklmb

    franklmb

    Joined:
    Jan 22, 2014
    Posts:
    1
    Hi,

    Sorry, I have not checked all the 13 pages messages for my question.

    Does it support mobile platform? how is the performance?

    Thanks a lot.
     
  31. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi Frank!

    Yes, it works on all platforms including mobile. From what I get from the feedback it seems to be working great.
    Performance is of course limited by the amount of chunks you create but it seems to be working pretty well. I can't give you exact numbers but what I can tell you is feedback has been really positive.

     
  32. JovanD

    JovanD

    Joined:
    Jan 5, 2014
    Posts:
    205
    Unity crashes whenever i make 13x13x13 or higher chunks, is there a way around it? I mean to avoid the crash.
    Also is there object limit in Unity?
     
  33. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi JovanD,

    13x13x13 is possible (I've just checked it) but it certainly is too much for the current state of Unity's physics engine. Unity uses PhysX, and currently performs rigidbody computations on the CPU which means it will be the bottleneck for high numbers of rigidbodies (in your case more than 2000).
    It is not supposed to crash though, just take more time to compute and run slow. It may be the mesh you are trying to fracture, if you can send it to info -at- ultimategametools com I'd be glad to check that out for you.
    Anyway, if you are trying to blow things up I would suggest using a lower number of chunks for performance reasons :)

     
  34. JovanD

    JovanD

    Joined:
    Jan 5, 2014
    Posts:
    205
    o/ Hello me again, forgot to say how freaking fun and awesome the tool is.
    I need a little guidance(im new to scripting), let's say there's a wall and when player fractures that wall how could i spawn a new wall directly behind the first wall and when player shoots that new wall another wall is instantiated behind that wall and like that to infinity?
    Also is there a way to implement a sort of DYI LOD system where there's a sphere or a box around the player and any game object outside of it is disabled until it's inside of it again? Since unity's LODculling system only works for renderer and leaves the objects to hog the performance :(
    Thanks in advance and keep up the good work :)
     
  35. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi Jovan, sorry for the late reply!
    As soon as I get back from the office I'll write you a little explanation :)
     
  36. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi JovanD,

    You would need to create a prefractured wall with the "Enable Prefab Usage" option set before computing the chunks.After that, make a prefab out of it and now you've got an instantiable fracturable wall.
    To instance the wall through scripting you can do simply:

    objNewWall = Instantiate(wallPrefab, new Vector3(x, y, z), Quaternion.Identity);

    How are you destroying the walls? Depending on how you destroy them, you can use the collision notifications (help here: http://www.ultimategametools.com/products/fracturing/scripting) in order to receive a notification and use it to spawn a new wall if the first chunk of the "old" wall was detached.

    Regarding LODs, you can use trigger colliders (http://unity3d.com/learn/tutorials/modules/beginner/physics/colliders-as-triggers) to disable the whole wall. In any case, the system right now is optimized to perform well if no chunks were detached from a wall, so no special physics will be computed meanwhile a wall is clean :)

     
  37. Cato_xyz

    Cato_xyz

    Joined:
    May 18, 2013
    Posts:
    60
    Hey, i'm trying to make this works with the UFPS but i dont know anything about scriting, do you know how to get it works?
    Thanks
     
  38. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi zertax!

    What do you need exactly? You will need some basic scripting knowledge to make it work

     
  39. Cato_xyz

    Cato_xyz

    Joined:
    May 18, 2013
    Posts:
    60
    I'm looking to break some wood objects with shoots of the UFPS asset, bu it does not work, i dont know how to code, so i dont know where to add the code lines you told to radiantboy
     
  40. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Can you upload it and send me a link to info at ultimategametools dot com? I will take a look at it

     
  41. StonePaleAle

    StonePaleAle

    Joined:
    Aug 20, 2012
    Posts:
    28
    @zertrax
    Are you using one of the weapons that comes with UFPS, or your own custom weapon?

    Do your wood fractured objects break at all when you shoot them?

    Do you have Start Static set to true on your fractured objects? (If yes, try setting it to false.)

    What is the total mass set to for your fractured objects?

    What is the force setting for your bullet prefabs? (If you are using the default weapons, this would be 100 for the pistol and machine gun, 600 for the revolver.)
     
  42. Cato_xyz

    Cato_xyz

    Joined:
    May 18, 2013
    Posts:
    60
    Hey thanks for the answers!

    Actually im using UPFS all default, i checked the paramenter you said and yes, they're Okay.

    The problem is the object does not break at all, when i put it as not static, the objetc falls down and im able to move the wood pieces.

    i tried the ufps player on the demo scene with columns and there is the same issue
     
  43. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi Zertrax,

    Did you script any logic so that the fracturing tool knows when an UFPS weapon hit it?

     
  44. SiMULOiD

    SiMULOiD

    Joined:
    Dec 23, 2013
    Posts:
    126
    Hi All,

    I'm trying to use the following script to call Explosive Force / Explosive Radius anywhere that the user
    touches the screen in iOS. Currently, this only seems to put the Explosive Force / Explosive Radius in the middle of the screen.
    Any ideas how to make it appear anywhere that the user touches?
    Thanks,
    Greg




    Code (csharp):
    1.  
    2.  
    3.     using UnityEngine;
    4.     using System.Collections;
    5.      
    6.     public class OnTouchDown : MonoBehaviour {
    7.        
    8.        
    9.             public enum Mode
    10.     {
    11.         ShootObjects,       // Will shoot physical objects
    12.         ExplodeRaycast      // Will raycast against the scene, finding fractured chunks and explode them
    13.     };
    14.  
    15.     public Mode              ShootMode          = Mode.ExplodeRaycast;  // The current shoot mode
    16.     public float             MouseSpeed         = 0.3f;                 // Mouse sensivity
    17.     public Texture           HUDTexture;                                // The texture to draw at the center
    18.     public float             HUDSize            = 0.03f;                // The size of the HUD to draw
    19.     public Color             HUDColorNormal;                            // HUD color when no raycast chunk was found
    20.     public Color             HUDColorRaycast;                           // HUD color when raycast chunk was found
    21.     public Transform         Weapon;                                    // The transform of the weapon, which should be child of this component assigned to a camera
    22.     public AudioClip         AudioWeaponShot;                           // The audio clip to play when a shot is fired
    23.     public float             WeaponShotVolume   = 1.0f;                 // The volume of the weapon shot
    24.     public float             ExplosionForce     = 1.0f;                 // The force to apply when FracturedChunk.Impact() is called.
    25.     public float             ExplosionRadius    = 0.4f;                 // The radius to apply when FracturedChunk.Impact() is called.
    26.     public float             RecoilDuration     = 0.2f;                 // The length of the recoil animation in seconds
    27.     public float             RecoilIntensity    = 0.05f;                // The intensity of the recoil
    28.     public GameObject        ObjectToShoot      = null;                 // In ShootObjects mode, the object to instance when shooting
    29.     public float             InitialObjectSpeed = 1.0f;                 // In ShootObjects mode, the initial speed of the object
    30.     public float             ObjectScale        = 1.0f;                 // In ShootObjects mode, the object's scale
    31.     public float             ObjectMass         = 1.0f;                 // In ShootObjects mode, the object's mass
    32.     public float             ObjectLife         = 10.0f;                // In ShootObjects mode, the object's life time (seconds until it deletes itself)
    33.  
    34.     private Vector3          m_v3MousePosition;
    35.     private bool             m_bRaycastFound;
    36.     private float            m_fRecoilTimer;
    37.     private Vector3          m_v3InitialWeaponPos;
    38.     private Quaternion       m_qInitialWeaponRot;
    39.        
    40.        
    41.            
    42.        
    43.      
    44.      
    45.     void Update()
    46.     {
    47.     // Code for OnMouseDown in the iPhone. Unquote to test.
    48.     RaycastHit hit = new RaycastHit();
    49.     for (int i = 0; i < Input.touchCount; ++i)
    50.     {
    51.     if (Input.GetTouch(i).phase.Equals(TouchPhase.Began))
    52.     {
    53.     // Construct a ray from the current touch coordinates
    54.     Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position);
    55.     if (Physics.Raycast(ray, out hit))
    56.     {
    57.        
    58.        
    59.        RaycastHit hitInfo;
    60.  
    61.                   FracturedChunk chunkRaycast = FracturedChunk.ChunkRaycast(transform.position, transform.forward, out hitInfo);
    62.                            
    63.                   chunkRaycast.Impact(hitInfo.point, ExplosionForce, ExplosionRadius, true);
    64.  
    65.  
    66.        
    67.          Debug.Log(" You just hit " + hit.collider.gameObject.name);
    68.  
    69.  
    70.     }
    71.     }
    72.     }
    73.     }
    74.      
    75.     }
    76.  
    77.  
    78.  
    79.  
    80.  
     
  45. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi there,

    You've done the most difficult step right on Physics.Raycast. After that you can replace what you have by:

    FracturedChunk chunkRaycast = hit.collider.GetComponent<FracturedChunk>();
    if(chunkRaycast != null) chunkRaycast.Impact(...)

    And you're done :)
     
  46. SiMULOiD

    SiMULOiD

    Joined:
    Dec 23, 2013
    Posts:
    126
    Thanks for the above answer, UGTools!

    Would you be able to answer another question?

    Is there a way to use two or more fractured objects together, creating dependencies,
    or sharing the same support plane? I tried using combine mesh, then fracturing, but the two objects seemed to have a lot of areas where the separate geometry was ignored, resulting in a single fractured volume.
    Any ideas how to keep them separate, but have fracturing work on both at the same time?
    Thanks,
    Greg
     
  47. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
  48. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Can you show me a screenshot with the "Show chunk connections" option enabled?

     
  49. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Hi there!

    I'm not sure since I haven't checked that tool. That exact feature is one of the things I'm expecting to have some time to implement! :)
    I may get in contact with the guy to see if it is compatible or not, since it would be interesting for the both of us.

     
  50. Paddington_Bear

    Paddington_Bear

    Joined:
    Dec 9, 2012
    Posts:
    274
    Cheers :)
    I'm sure you're tool isn't too performance heavy but the project will require minimal simulations due to the vast number of other processes.
    Please send me a PM or email if you get a reply from the author and I'll be sure to pick up the required number of licences for this extension.
    Thanks again