Wedges, as triangles, do not have a vector that can easily tell where they are facing.
They just have the classic vectors, such as LookVector, RightVector, and UpVector.
I think I could use RightVector and LookVector along with the sizes to calculate the direction the wedge’s face is pointing, but I have no idea how.
function module.GetWedgeFaceDirection(Wedge:BasePart)
local z = Wedge.Size.Z
local y = Wedge.Size.Y
local NewVector = (Wedge.CFrame.LookVector*z) - (Wedge.CFrame.UpVector*y)
return NewVector
end
Making a part face the direction
local Direction = module.GetWedgeFaceDirection(script.Parent)
local PartOrientation = CFrame.lookAt(script.Parent.Position, script.Parent.Position+Direction)
other stuff
-- Flips a wedge while keeping the same looks.
function module.WedgeFlip(Wedge:BasePart)
local Targets:BasePart = {Wedge}
for _, Target in Targets do
local Orientation = Target.Orientation
Target.Orientation = Vector3.new(Orientation.X, Orientation.Y-90, Orientation.Z-180)
local X = Target.Size.X
local Y = Target.Size.Y
local Z = Target.Size.Z
Target.Size = Vector3.new(X, Z, Y)
end
end
-- Returns the length of a wedge's slope.
function module.GetWedgeSlopMagnitude(Wedge:BasePart)
local Origin = Wedge.Position
local Y = Wedge.Size.Y/2 -- UpVector
local X = Wedge.Size.X
local Z = Wedge.Size.Z/2 -- LookVector
local CornerA = (Wedge.CFrame.LookVector*Z) - (Wedge.CFrame.UpVector*Y)
local CornerB = -(Wedge.CFrame.LookVector*Z) + (Wedge.CFrame.UpVector*(Y))
return (CornerA-CornerB).Magnitude
end