RealDocs

UKismetMathLibrary::Atan2

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

Description

Returns the full-circle arc tangent of Y/X in radians, correctly handling all four quadrants. The result is in the range (-π, π].

Caveats & Gotchas

  • Parameter order is Atan2(Y, X) — swapping them gives the complementary angle, a subtle bug that is hard to spot at runtime.
  • When both Y and X are zero the result is 0 by convention, but this case often indicates a degenerate direction vector that should be guarded against upstream.

Signature

static UE_INL_API double Atan2(double Y, double X);

Parameters

Name Type Description Default
Y double The Y component (numerator).
X double The X component (denominator).

Return Type

double

Example

Yaw angle of a 2D direction C++
FVector Dir = (TargetLocation - MyLocation).GetSafeNormal();
double YawRad = UKismetMathLibrary::Atan2(Dir.Y, Dir.X);
double YawDeg = UKismetMathLibrary::RadiansToDegrees(YawRad);

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.