RealDocs

UKismetMathLibrary::DotProduct2D

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

Description

Returns the dot product of two 2D vectors. A result of 1 means the vectors point in the same direction; 0 means perpendicular; -1 means opposite.

Caveats & Gotchas

  • This operates in 2D only — the Z component is ignored. Use DotProduct (3D) when working with FVector.
  • The result is not automatically clamped to [-1, 1]; for unnormalized inputs the magnitude can exceed 1, so normalize both vectors first if you need a cosine angle comparison.

Signature

static UE_INL_API double DotProduct2D(FVector2D A, FVector2D B);

Parameters

Name Type Description Default
A FVector2D First 2D vector.
B FVector2D Second 2D vector.

Return Type

double

Example

Check if two UI directions are aligned C++
FVector2D MoveDir = FVector2D(1.f, 0.f);
FVector2D AimDir = FVector2D(0.7f, 0.7f).GetSafeNormal();
double Dot = UKismetMathLibrary::DotProduct2D(MoveDir, AimDir);
// Dot ~0.707 — roughly 45 degrees apart

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.