What is the appropriate equations for smashable glass?
So here is what I've stuck together, and has some ALRIGHT results, looking like this:
https://gyazo.com/f7a370680579f3669a9522db4e2a6e1a
The bits in front are products of the script, and the bit behind is a replica of the part that was converted
01 | local event = game.ReplicatedStorage.Remotes.Weapon.Smash |
03 | function event.OnServerInvoke(plr, objHit) |
05 | local size = objHit.Size |
06 | local centerpos = objHit.Position |
07 | local width = size.X / 3 |
08 | local hight = size.Y / 3 |
09 | local x 1 = centerpos.X * 2 |
11 | local y = centerpos.Y * 2 |
13 | local position = Vector 3. new(x 2 , y 2 , centerpos.Z) |
14 | local sizenew = Vector 3. new(width / 3 , hight / 3 , size.Z) |
15 | local positions = { { position.X, position.Y, position.Z } , { position.X + width, position.Y, position.Z } , { position.X + (width * 2 ), position.Y, position.Z } |
16 | , { position.X, position.Y - hight, position.Z } , { position.X + width, position.Y - hight, position.Z } , { position.X + (width * 2 ), position.Y - hight, position.Z } , |
17 | { position.X, position.Y - (hight* 2 ), position.Z } , { position.X + width, position.Y - (hight* 2 ), position.Z } , { position.X + (width * 2 ), position.Y - (hight* 2 ), position.Z } } |
19 | objHit.CanCollide = false |
22 | local pos = positions [ i ] |
23 | local shard = Instance.new( "Part" , workspace) |
24 | shard.Transparency = objHit.Transparency |
25 | shard.Reflectance = objHit.Transparency |
26 | shard.Anchored = false |
27 | shard.CanCollide = true |
28 | shard.FormFactor = Enum.FormFactor.Custom |
30 | shard.Position = Vector 3. new(pos [ 1 ] , pos [ 2 ] , pos [ 3 ] ) |
35 | objHit.Transparency = 1 |