Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

how to make Destructible Glass

Discussion in 'General Discussion' started by Marwan_Ayyad, Apr 1, 2014.

  1. Marwan_Ayyad

    Marwan_Ayyad

    Joined:
    Apr 1, 2014
    Posts:
    12
    i would love to make Destructible object like that game have, it's mobile game and it very beautiful graphics (Glass Graphics)
    Please Help because i totally lose here , dont kow from where to start
    all i want to do is (break part of the glass but not all of it and the breaking depend on the force that impact with the glass)
    https://www.youtube.com/watch?v=loNM3mwFHGU

    PS: i can make Destructible object but Glass!! it's another things

    sorry for my poor english :)
     
  2. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    without getting into doing dynamic geometry slicing or anything like that in Unity.. just create both versions of the object offline in your modeling program. First create all your solid objects and then for each solid object, add extra loops split edges alter uv maps etc but maintain the same shape obviously.

    Then at run time you have the solid objects in scene, on collision you remove that object and replace it with the appropriate object made of several pieces and animate the pieces... simple.
     
  3. Marwan_Ayyad

    Marwan_Ayyad

    Joined:
    Apr 1, 2014
    Posts:
    12
    i did that already but lets take that example : if u have big wall from Glass and u throw a ball to the center of the wall glass , the ball will leave a hole in the wall with shattered glass , but all of the wall glass will not shatter , just the place of the impact of the ball.

    PS: i not that advance to do complex thing, i just learn unity from a month
     
    Last edited: Apr 1, 2014
  4. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    something like that would probably be better to use some decal / cutout shader and a particle effect for the glass pieces. Since you are only using Unity for one month I would think this would be way beyond your abilities. Either you can look for a pre-built asset you can purchase that does what you need or you can pay someone to build it for you..
     
  5. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    You could probably have it broken into multiple fragments before hand all as kinematic rigidbodies with the same parent. Then when you hit the glass change isKinematic to false for the pieces within a certain distance of the center. You could probably also attach all the fragments with breakable joints but I'm not sure how well that would work.

    In the game you linked to they are probably calculating and creating the fragments at runtime which to do well you would need a very good understanding of the math involved (probably complex), a good understanding of creating meshes at runtime from code, and you would need to know how to program across multiple threads to get it to perform well.
     
  6. khelegond

    khelegond

    Joined:
    Nov 20, 2012
    Posts:
    13
  7. Marwan_Ayyad

    Marwan_Ayyad

    Joined:
    Apr 1, 2014
    Posts:
    12
    i thought exactly like u , i will design the glass as fragments then will give them rigidboy and make isKinematic True then throw a ball to the glass and turn isKinematic false to the fragments that collide with the ball . i will test this and tell u if it going to work or not but i am sure it will work.
     
  8. Marwan_Ayyad

    Marwan_Ayyad

    Joined:
    Apr 1, 2014
    Posts:
    12
    it worked like i expect , but it need to better than that , i thought if i can get the force of ball impact to glass and loop on all fragments of the glass to turn in isKinematic to false ,all that's depending on the force of the impact and where the ball it going to hit the glass (more power the ball have more fragments will fall .
     
  9. minionnz

    minionnz

    Joined:
    Jan 29, 2013
    Posts:
    391
    Instead of isKinematic, try putting the fragments to sleep using RigidBody.Sleep() - I'm not sure how well (or if) it will work, but a sleeping rigidbody is not affected by forces (eg gravity) until it is woken up. The ball hitting the glass will wake up the fragment rigidbodies.

    You may also have to tweak/reduce the size of each fragments collider to get the effect you want.
     
    Last edited: Apr 2, 2014