UKismetMathLibrary::Vector_Distance2DSquared
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the squared XY-plane distance between two 3D points without a square root. The fastest option for top-down 2D range comparisons.
Caveats & Gotchas
- • Z is ignored entirely — same caveat as Vector_Distance2D. Combining this with 3D distance checks requires a separate call to Vector_DistanceSquared.
- • Compare the result against a squared threshold (Radius * Radius), not the raw radius. This is easy to forget when porting a non-squared check.
Signature
static UE_INL_API double Vector_Distance2DSquared(FVector V1, FVector V2); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| V1 | FVector | The first point. | — |
| V2 | FVector | The second point. | — |
Return Type
double Example
Efficient top-down proximity check C++
double DistSq2D = UKismetMathLibrary::Vector_Distance2DSquared(
GetActorLocation(),
TargetActor->GetActorLocation());
if (DistSq2D <= Radius2D * Radius2D)
{
OnEnterZone();
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?