UKismetMathLibrary::Conv_VectorToQuaternion
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns the FQuat orientation corresponding to the direction the vector points, with zero roll. Equivalent to converting via Conv_VectorToRotator and then to quaternion.
Caveats & Gotchas
- • Roll is always zero, just as with Conv_VectorToRotator. If you need roll, construct the quaternion explicitly using FQuat(Axis, AngleRad) or FRotator's Quaternion() method.
- • Passing a zero-length vector produces an invalid (degenerate) quaternion. Always guard with InVec.IsNearlyZero() if the vector may be zero.
- • This is a BlueprintAutocast node. Blueprint silently inserts it when a Vector is wired to a Quat input — the zero-roll constraint can be a non-obvious source of bugs.
Signature
static UE_INL_API FQuat Conv_VectorToQuaternion(FVector InVec); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InVec | FVector | A direction vector to convert into an orientation quaternion. | — |
Return Type
FQuat Example
Rotate a mesh component to face an aim direction C++
FVector AimDir = (Target->GetActorLocation() - Turret->GetActorLocation()).GetSafeNormal();
FQuat AimQuat = UKismetMathLibrary::Conv_VectorToQuaternion(AimDir);
TurretMesh->SetWorldRotation(AimQuat); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?