RealDocs

UKismetMathLibrary::Sqrt

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

Description

Returns the square root of A. For performance-sensitive inner loops prefer FMath::InvSqrt or FVector::Size which can use hardware fast-paths.

Caveats & Gotchas

  • Passing a negative value returns NaN; in gameplay code distances and squared lengths can sometimes be negative due to floating-point cancellation, so guard with FMath::Max(0.0, A) before calling.
  • In tight loops that only need a comparison (e.g. is distance < threshold), compare squared values instead of calling Sqrt — FVector::SizeSquared avoids the sqrt entirely.

Signature

static UE_INL_API double Sqrt(double A);

Parameters

Name Type Description Default
A double The value to compute the square root of. Should be >= 0.

Return Type

double

Example

Compute distance between two points C++
FVector A = GetActorLocation();
FVector B = OtherActor->GetActorLocation();
double DistSq = FVector::DistSquared(A, B);
double Dist = UKismetMathLibrary::Sqrt(DistSq);

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.