How to make Breakable Glass

it to be a random point or where the touch is?

1 Like

a random point. Because it’s an explosion near the glass.

1 Like

u should use my idea but with very much break glasses and math.random() but to detect if the glass is touched by the explozion u need to use

UR_EXPLOZION.Hit:Connect(function(part)
if part.Name == "UR_GLASS_NAME" then
--Do stuff

end)
end

1 Like

I’m not talking about when to break the glass.
I’m talking about generating eight pieces of glasses.

2 Likes

sorry i can’t make what u want

1 Like

I found something on roblox forums:

Hope it helps : )

1 Like

I saw that, but I still can’t figure out how to make it.(Before you replied me XD)

1 Like

Well, in that post @Fractality_alt says:

I did a quick search on Fortune’s algorithm.

Wikipedia says “Fortune’s algorithm is a sweep line algorithm for generating a Voronoi diagram”

I think a Voronoi diagram simulates breaking glass. Again, Wikipedia says “In mathematics, a Voronoi diagram is a partition of a plane into regions close to each of a given set of objects”

Here’s the Fortune’s algorithm in action, creating a Voronoi diagram out of random points. (Found on Wikipedia)

IMG_3248

So @Fractality_alt is saying that you run that algorithm with random points on the window, which are the points where the glass will break. Then, convert the Voronoi regions into wedge parts, and like @pro_developer213 said, teleport them to replace the unbroken glass with them. Then, following @Fractality_alt’s instructions, apply VectorForce to each part? I’m not sure what that means, but it may be important.

@Fractality_alt’s way doesn’t make the glass break into exactly eight pieces, but it simulates broken glass.

2 Likes

Yeah, but umm. How can I calculate it? bruh

1 Like

I found a detailed explanation on the web, but I don’t understand that much advanced math, so I can’t help you that much :frowning:.

But hey, on the bright side I found some code for the Fortune’s algorithm written in Lua.

You should put that code, like, in a modulescript, and require that code inside you main breaking glass code, since if you directly imbed it inside your main code, it might get messy :smile:

1 Like

Bruh that would will be very hard work.
Come on, Thousands of lines.

1 Like

Yeah, sadly it is :joy:

If you’re not that much of a math wiz, I’ll try to find something easier for you. :sweat_smile:

1 Like

I looked at the picture in your original post. It looks like the eight triangular parts form out four rectangles:

PNG

I think you can find out the wedge parts’ width and height by subtracting the coordinates of the impact point and the x and y coordinates of the corners of the glass, since its dimensions are the same as the rectangles. Then, you just rotate the parts so that the crack aligns with the impact point.

Maybe, this would be easier for you?

In my opinion, this approach is harder to implement than the Fortune’s algorithm, because you have to do all the rotating, and positioning them so they all fit together. (The choice is up to you :slight_smile:)

5 Likes

I wanted to do it like you said, but I don’t what I’m gonna do with CFrame.

1 Like

F point is the position of the Orange rectangle
E point is the position of the blue rectangle
G point is the position of the Green rectangle
H point is the position of the purple rectangle

2 Likes

So, the triangles in the same rectangle has the same size and position.

2 Likes

I was thinking of the concept of not creating new instances of a wedge and then patch it up, making it look like the rectangular glass just broke, but instead actually cut up the glass so the rectangular glass actually ‘broke’

After quickly searching ‘cutting parts roblox’, I found this interesting post:

There’s a lot of solutions to that post, but the accepted answer was by @Syharaa:

Unfortunately, @EgoMoose’s roblox place for the answer is closed…

I found many alternate solutions other than @EgoMoose’s, like @Hexlinee’s, in the thread. And @skwoginc’s answer. Although I haven’t looked into all of them yet, but it’s worth looking into.

4 Likes

I think I should use the cut technology.
Bc it looks easier.

Bruh it’s hard.

1 Like

I guess I should make a handmade one.

1 Like

Maybe make the glass a model made by more parts and when .Touched, use BreakJoints function.

1 Like