UKismetMathLibrary::VSize2DSquared
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns the squared Euclidean length of a 2D vector. Cheaper than VSize2D because it skips the square root. Use this when you only need to compare distances.
Caveats & Gotchas
- • Compare against the squared threshold, not the raw threshold. To check if the distance is less than 100 units, compare VSize2DSquared against 10000, not 100.
- • For NormalSafe2D, the Tolerance parameter is also a squared length threshold — this is consistent with VSize2DSquared conventions.
Signature
static UE_INL_API double VSize2DSquared(FVector2D A); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector2D | The 2D vector whose squared length to compute. | — |
Return Type
double Example
Fast distance check without sqrt C++
FVector2D Delta = FVector2D(ActorPos) - FVector2D(TargetPos);
if (UKismetMathLibrary::VSize2DSquared(Delta) < 10000.0) // < 100 units
OnTargetReached(); See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?