Hello recently ive been wanting to make glass breaking physics, since im not so advanced at trigonometry I opted for a more simpler way to do it so for my method I have decided to split my block part into 4 and then replace them by 2 wedges each so they look like shards!.
The issue is the only way I can currently make this system is by setting al my glass structure to face a specific way so they break from that face. So I would like to find a way to determine an objects largest face so then it can shatter into pieces from that face and make the wedges face the object’s largest face too.
If you have a way to do this please let me know I have tried everything I thought of and read other dev forum posts but they arent that clear or dont really give me the knowledge i am looking for.
function getLargestAxis(part: Part): Enum.Axis
local x, y, z = part.Size.X, part.Size.Y, part.Size.Z
local min = math.min(x, y, z)
if min == x then
return Enum.Axis.X
elseif min == Y then
return Enum.Axis.Y
else
return Enum.Axis.Z
end
end
The largest pairs of faces will always be on the axis where the size is smallest. E.g. having a large X size makes the Y and Z faces larger, not the X faces.
you cant possible get its largest face but you can gets its largest side just like @ThanksRoBama (sorry for the ping) explained in a very clever way tbh
Thats kinda what I wanted, Yeah I should have said pair of 2 faces, since we are on the 3rd dimension and a really only has 3 different sizes on the faces since all faces underneath or above them have the same size, Ill take a read from the function the guy sent.
This is usefull since i can kinda work arround your code to get the 2 largest axis to know that the smallest axis is the face were we want the glass to shatter
for example we know that the X and Y axis make up the height and with of the face were we want the glass to shatter from, wich leaves us with the Z axis were our part should look for, Now how can I make it so a part looks at the large face and how can I get where it should look at of this object? (Aka the glasss shards) so it breaks like this