Math question. finding distance to the edge of a plane in direction from center.

Not sure if I get the question right (drawing would help), how about this

// FVector PlaneDirX, PlaneDirY
// FVector2D PlaneExtent
// FVector Direction

// Get the contribution of Direction to each side of the plane (avoiding zero edge case)
FVector2D Projected = FVector2D(
   FMath::Max(0.01f, FMath::Abs(Direction.Dot(PlaneDirX))),
   FMath::Max(0.01f, FMath::Abs(Direction.Dot(PlaneDirY)))
).GetSafeNormal();  //normalize in case Direction was not exactly in-plane

// Use division to calculate the amount of times we can fit each component into Extent/2
FVector2D Dist = (PlaneExtent / 2) / Projected;

// Return nearest one
return Dist.GetMin();

Looking at your blueprint you have a rotator for the plane orientation. You should be able to get plane axis directly from that rotator :

FVector PlaneDirX = Rotation.GetForwardVector();
FVector PlaneDirY = Rotation.GetRightVector();

(might have to replace one of those with GetUpVector() depending on how the orientation of the platform is set up)

1 Like