The red parts are the ones identified as being close to the top of the wall. Next, I need to detect all the edges: Left, Right, Top, and Bottom to achieve this result:
I have no idea if this will work but in my head it will but:
Assuming the wall will always be the same size you could add detection boundaries around where the wall will be and all the parts which touch said boundaries will ofc be the ones closest to the edges.
If it’s not always the same size however you could still use detection boundaries it’s just you could just move the boundaries out until no parts are detected then you could move the boundaries in and then the next time a part is detected then you would know that is the edge???. Either that or you could try finding where the edge is using part positions.
When you refer the wall as edges I am going to imply that you are referring edges as the sides of the wall. Left, Right, Up and Down. So what you can do in this case is most likely acquire the CFrame position of each side length
--Implying that the wall's lookvector is facing directly at you
local Wall = targetpart
local RightSideLength = Wall.CFrame * CFrame.new(-Wall.Size.X/2,0,0)
local LeftSideLength = Wall.CFrame * CFrame.new(Wall.Size.X/2,0,0)
local TopSideLength = Wall.CFrame * CFrame.new(0,Wall.Size.Y/2,0)
local LeftSideLength = Wall.CFrame * CFrame.new(0,-Wall.Size.Y/2,0)
This code gives you the CFrame of each edge or side length if thats what you are looking for
Keep in mind that the positions given for each side length in the above code gives you the position of the side lengths middle. What you are going to have to accomplish is for each part find the closest side length and just keep rounding down for that specific edge.
(This topic is about a very specific problem, but I’ll leave my solution anyway.)
I found the solution and it was much easier than I thought. It was a mix of @Provenoc and @helpfulllukemaster1 I simply used:
function PosIsInPart(Pos, PartCF, PartSize)
local RelativePos = PartCF:PointToObjectSpace(Pos)
return (math.abs(RelativePos.X) <= PartSize.X / 2)
and (math.abs(RelativePos.Y) <= PartSize.Y / 2)
and (math.abs(RelativePos.Z) <= PartSize.Z / 2)
end
to know if the CFrame of the edge is inside the part, changing the CFrame of the vertical edge so that the Y axis is equal to that of the part so that the vertical point is the same, same with the horizontal CFrame and the X
if PosIsInPart(Vector3.new(LBound.Position.X, PartPos.Y, LBound.Position.Z), PartCFrame, PartSize) then
--Left Border/Edge
end