Glass Shattering System

Hello world!

I would like to show you something I have been working on for a week (in which I had the idea in mind long ago)!

It’s a type of glass shatter I have made. The way it shatters is that it makes a straight line from the hit/click position to every corner, as well as the closest point to every edge. Essentially creating 8 right angled triangles (using WedgeParts of course). This is my very first creation (and post) that I have showcased onto DevForum. And to my knowledge, I am the first person to make this type of glass shatter (according to quick searches related to glass shatter, other than my own post in ScriptingHelpers long ago)

The shattering will work anywhere you click on it, not just on 1 face of the glass.

If you would like to test this out yourself, here is the game link

I would like to point out a few things:

  1. The script errors (but doesn’t break) if you click and immediately move the mouse outside of the glass (returning a nil error in console).
  2. If you spam click fast enough, you are able to duplicate the shards of glass.
  3. The glass object itself cannot have any rotations, otherwise the shards are not correctly created (not for self really, since you guys are only testing it).

Hope you guys enjoy trying it out!

8 Likes
  1. Use a nil check before continuing, just to make sure it doesn’t actually break anything.
  2. Use a boolean attribute or tag to check if the glass was already shattered.

As for my feedback:

  1. I think you should be able to shatter large shards, it would feel more satisfying.
  2. The glass is a little too thick to walk into when you shatter it, I know it’s just the default city map but I would make the glass thinner.

Overall, I think this was a good showcase. I hope you can expand on this and find a nice use case in a larger game!

I have a sort of realism suggestion; The audio that plays contains what I think is glass pieces falling. I suggest cutting it right before the glass falls.

(Also, i do have major hearing loss so i could be completely wrong, apologies if so.)

1 Like

Oh, alright. Well initially I didn’t add audio because I wanted to showcase just the creation of the wedges, so audio wasn’t a priority. But I guess I could cut off the audio so you don’t hear the glass falling. Thank you though.

1 Like

Will this ever be open source?

No, sorry. Not sure if you can find some resources for it as I just did all of this without any internet (also took me a lot of time). My code is not optimised as seen in the little notes I sent at the end of the post.

Best of luck if you ever plan on making it for yourself!