RealDocs

UKismetMathLibrary::Box_GetClosestPointTo

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPureUFUNCTION

Description

Calculates the point on the surface of (or inside) a bounding box that is nearest to a given world-space point. Use this to find where an external object is closest to a volume for proximity checks or push-out logic.

Caveats & Gotchas

  • When Point is inside the box, the function returns Point itself unchanged — not the nearest surface point. If you need the nearest surface point for an interior query (e.g. push-out), clamp the result manually to the box faces.
  • The result is always clamped to [Box.Min, Box.Max] per axis, so the output is guaranteed to lie within or on the box — it is never extrapolated outside.

Signature

static ENGINE_API FVector Box_GetClosestPointTo(const FBox& Box, const FVector& Point);

Parameters

Name Type Description Default
Box const FBox& The axis-aligned bounding box.
Point const FVector& The reference point in world space.

Return Type

FVector

Example

Compute distance from a character to the edge of a trigger zone C++
FBox ZoneBounds = TriggerActor->GetComponentsBoundingBox();
FVector PlayerPos = Player->GetActorLocation();
FVector ClosestPt = UKismetMathLibrary::Box_GetClosestPointTo(ZoneBounds, PlayerPos);
float DistToZone = FVector::Dist(PlayerPos, ClosestPt);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.