RealDocs

UKismetMathLibrary::DistanceSquared2D

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

Description

Returns the squared Euclidean distance between two 2D points without computing a square root. Prefer this over Distance2D whenever you only need to compare distances.

Caveats & Gotchas

  • The returned value is distance squared — comparing it against a threshold requires squaring the threshold too (use ThresholdSq = Threshold * Threshold). A common bug is comparing DistanceSquared2D output directly against an unsquared radius.
  • Not to be confused with Vector_Distance2DSquared, which operates on FVector (3D) inputs and ignores Z.

Signature

static UE_INL_API double DistanceSquared2D(FVector2D V1, FVector2D V2);

Parameters

Name Type Description Default
V1 FVector2D The first 2D point.
V2 FVector2D The second 2D point.

Return Type

double

Example

Efficient proximity check without sqrt C++
FVector2D A(0.f, 0.f);
FVector2D B(30.f, 40.f);
float Radius = 50.f;
if (UKismetMathLibrary::DistanceSquared2D(A, B) < Radius * Radius)
{
    // Within range — no sqrt needed
}

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.