Hey guys, im having a bit of trouble with some Math, i probably should have posted in the C++ section but im doing it in BPs so yeah.

Im trying to find the start point for a line trace within a box that can be scaled and rotated and all that jazz, but the Math i worked out myself just doesnt take into account the rotation of the box.

I solved it by just getting a vector from each side of the rectangle and transforming it to rectangle local, and transforming the point in space to rectangle comp local.
Then just checking if point.X is >= rectangleXMinusSide.X && point.X <= rectangleXPlusSide.X.

Then do the same for yLeft and Right Side, and zUp and Down side.

The sides are easy to get if you have the component and its scale, here’s an example:
isVertexWithinArea_SquareXSize = rectangleComponent->GetRelativeScale3D().X * 100;

Now you can use the component location + its forward vector * isVertexWithinArea_SquareXSize / 2 to get+ side of the rectangle. Same thing for the minus side you just *-1 on the forward vector as well.

This solution supports rotated rectangles as well.