RealDocs

UKismetMathLibrary::GetPointDistanceToLine

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

Description

Returns the perpendicular distance from a point to an infinite line. Unlike GetPointDistanceToSegment, the line has no endpoints.

Caveats & Gotchas

  • LineDirection must not be zero; no safety check exists and passing a zero vector causes a divide-by-zero.
  • Returns only the scalar distance, not the closest point. Pair with FindClosestPointOnLine when you also need the position of the nearest point on the line.

Signature

static UE_INL_API float GetPointDistanceToLine(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 line. Does not need to be normalized.

Return Type

float

Example

Check if a projectile passes through a cylindrical corridor C++
float DistToAxis = UKismetMathLibrary::GetPointDistanceToLine(
    GetActorLocation(), CorridorOrigin, CorridorDirection);
if (DistToAxis < CorridorRadius) { /* inside volume */ }

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.