Dividing Part into 8 Pieces based on where touched (Glass Shatter)

Hello DevForum! So recently I have been interested in improving by building skills and I just thought of a nice feature for my game. Glass that breaks/shatters when hit by a raycast/object. I have been looking at the DevFourm and I found a topic that explained that you should divide the part into 4 pieces and then into another 4 pieces off of the hit position.

The problem is, I am a new scripter and have no idea how to divide the part into 8 pieces based on the position it was hit. Here is what I’m talking about. (This is for the glass shatter)

Window
(Images from this post)

Do you see how the script knows where the projectile hit, and divided the part into the according to 8 pieces? That is what I’m going for.

I have tried so many things but it’s 8 PM right now and I have had a pretty tiring day. I know this is possible, I just can’t think of anything that I could do. Also, I really would like this to be based on where the projectile hit, so I do not want to just make a bunch of shattered parts and make them visible when the glass is broken.

Please go easy on me, I am pretty new. Thank you! :grin:

Woohoo first topic created! :partying_face:

2 Likes

I actually created a module that does just this a while back! Feel free to examine the code.

It essentially divides the surface into four quadrants based off of as center point, and then converts those quadrants into triangles.

2 Likes

Wow! Just tested it out!

Do you know if there is a way to make it break from the point it was hit? Yours seems to break from the middle regardless of where is gets hit from. (Correct me if I’m wrong!)

Actually it should have a way to input a center point. As you can see in the BreakSurface explanation, there is a parameter called BreakOriginPositionVector, that allows you to input the center point to break from.

I may have forgotten to incorporate this into the videos, which is why it doesn’t appear to have this feature.

1 Like

Thank you! This is a great resource. :grin:

1 Like