Is it possible to get a Vector2 or the area of like the bottom of a part? Let’s say the size of a part was like
Vector3.new(2, 4, 2)
if you got the bottom surface, the area would be Vector2.new(2, 2)
Like the total area of x and z ?
Yeah, and including the length
local part = script.Parent
local x = part.Size.X
local y = part.Size.Z
print(x*y)
smthing like this?
yeah, but with the addition of normalId. Like if you had the top side, I would need the dimensions
U mean like the total volume
local part = script.Parent
local x = part.Size.X
local y = part.Size.Y
local z = part.Size.Z
print(x*y*z)
No, I just want the dimensions and the area from normalId.
Sorry I cant help furthermore but this
local Part = script.Parent
local v = Part.Size.CFrame.LookVector.X
local z = Part.Size.CFrame.LookVector.Z
print(v*z)
1 Like
They key concept is that whichever axes have a value of 0 on the Vector3 constructed from Vector3.FromNormalId are the ones that contribute to the surface’s area. With that in mind, either you could just map out the expected values with a couple if statements:
local enum = Enum.NormalId
if (normalId == enum.Top or normalId == enum.Bottom then
return Vector2.new(size.x, size.z)
elseif (normalId == enum.Left or normalId == enum.Right) then
return Vector2.new(size.y, size.z)
else
-- either front or back
return Vector2.new(size.x, size.y)
end
or a little math (although it’s a Vector3, the axis not being considered for the surface’s area will be 0):
local v = Vector3.FromNormalId(Enum.NormalId.Top)
local size = Vector3.new(2, 4, 2)
local area = Vector3.new(
(1 - math.abs(v.x)) * size.x,
(1 - math.abs(v.y)) * size.y,
(1 - math.abs(v.z)) * size.z
)
1 Like