UKismetMathLibrary::Dot_VectorVector
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the dot product of two 3D vectors (A.X*B.X + A.Y*B.Y + A.Z*B.Z). For unit vectors the result is cos(angle), making it the standard tool for checking if two directions are aligned.
Caveats & Gotchas
- • The dot product is only equal to cos(angle) when both input vectors are unit length. If you are using raw (non-normalized) vectors the result is scaled by the product of their magnitudes and cannot be directly interpreted as an angle cosine.
- • Returns a double in UE5; Blueprint exposes this as a float pin, so precision loss occurs when consuming the result in Blueprint on values where the magnitude of A and B is large.
Signature
static UE_INL_API double Dot_VectorVector(FVector A, FVector B); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FVector | First vector. | — |
| B | FVector | Second vector. | — |
Return Type
double Example
Check if the player is facing the enemy within 45 degrees C++
FVector Forward = Player->GetActorForwardVector(); // already normalized
FVector ToEnemy = (Enemy->GetActorLocation() - Player->GetActorLocation()).GetSafeNormal();
double DotVal = UKismetMathLibrary::Dot_VectorVector(Forward, ToEnemy);
bool bInFront = DotVal > 0.707; // cos(45 deg) Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?