RealDocs

UKismetMathLibrary::FindClosestPointOnLine

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

Description

Returns the closest point on an infinite line to a query point. Unlike FindClosestPointOnSegment, there are no endpoints — the line extends infinitely in both directions.

Caveats & Gotchas

  • LineDirection must not be zero; no safety check exists and a zero vector causes a divide-by-zero. Validate the direction before calling in data-driven contexts.
  • For finite segments with clamping to endpoints, use FindClosestPointOnSegment. Mixing up the two silently produces wrong results when Point lies beyond a segment's end.

Signature

static ENGINE_API FVector FindClosestPointOnLine(FVector Point, FVector LineOrigin, FVector LineDirection);

Parameters

Name Type Description Default
Point FVector The query point.
LineOrigin FVector Any point on the infinite line.
LineDirection FVector Direction of the infinite line. Does not need to be normalized.

Return Type

FVector

Example

Find the nearest position on a train track axis to the player C++
FVector PlayerPos = GetActorLocation();
FVector NearestOnTrack = UKismetMathLibrary::FindClosestPointOnLine(
    PlayerPos, TrackOrigin, TrackDirection);

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.