Realistic Glass?

Ok so for a long time I have been wondering how to make glass that can break when it is shot or hit with a certain speed… So I was wondering if anyone knew how to make glass that…

  • Breaks at a certain speed
  • Can be Shot or struck and break
  • If Shot struck or hit breaks into smaller fragments
  • The glass regenerates with no glass debris after a certain amount of time so it looks normal
  • Also realistic sound
8 Likes

Here is my own version of glass breaking… no sound for my recording software

  1. Idk what you mean by “Breaks at certain speed”
  2. Making it break when shot or struck is simply how you trigger it. There’s a lot of ways
  3. Use the same function that was used to break the glass in the first place
  4. game:GetService(“Debris”):AddItem(GlassModelContainer, GlassDebrisLifeTime)
  5. It looks like its just a normal sound being played when the fracturing is triggered.

Im assuming you really want to know how to actually program the code to break in the first place. What I did is use the new live CSG code to recursively split each in half at a random angle. To make it pop in fast it is generated during the game intermission and just parented when the “Hold E” is completed.

8 Likes

I just want breakable glass like what was shown in @CloneTrooper1019s video…

“Breaks at certain speed” can be done simply by binding .touched and checking for Instance.Velocity.
About shattering the glass itself,
it looks like random Wedges are generated in the same position as the part before breaking.
Can’t really go in-depth about that yet as I have never done something like that before,
but you could possibly make 2 or 3 preset “Shattered glass” models and have a math.random decide which to spawn in place of your glass that’s being shattered.

I made some realistic glass a while ago.
https://twitter.com/LocardRBX/status/973367644429500416

The hardest part for me was generating the glass fragments. That’s when I learned how to do it online where the articles I studied are kinda long forgotten unfortunately. :frowning:

These fragments are all just 2 wedge parts welded to each other. The shatter point is the origin and then from there it defines a boundary region (aka the whole glass part’s size). I then took a few points and placed them around the boundary, with a weight drawing it closer to the point of impact. That’s when I just did some triangulation and finally you have your glass shattering. :slight_smile:

I also gave them a velocity based on a ratio between the edge of the part and the point of impact. The closer it is to the impact, the closer its velocity will be to that of the item that hit it.

4 Likes

Generate fragments like the above or use the realtime union functions to recursively cut objects. For the speed stuff you can do things like impact force detection by checking abrupt changes in velocity and calculating the acceleration between them

2 Likes
  1. Find where the bullet hits the window
  2. Find random points on the window surface
  3. Run Fortune’s algorithm on the points
  4. Turn the Voronoi regions into convex polygons made of WedgeParts
  5. Apply a VectorForce to each polygon
11 Likes