UKismetMathLibrary::RandomUnitVectorInConeInDegrees
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Convenience wrapper around RandomUnitVectorInConeInRadians that accepts degrees. Returns a random unit vector within a symmetric cone around ConeDir.
Caveats & Gotchas
- • This is an inline function — it converts degrees to radians and delegates. In C++ hot paths, call the radians variant directly to avoid the conversion overhead.
- • Not thread-safe (NotBlueprintThreadSafe); shares the global FMath random state with all other non-stream random functions.
Signature
static FVector RandomUnitVectorInConeInDegrees(FVector ConeDir, float ConeHalfAngleInDegrees) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ConeDir | FVector | Center direction of the cone. | — |
| ConeHalfAngleInDegrees | float | Half-angle of the cone from its axis to its edge, in degrees. | — |
Return Type
FVector Example
Fire a shotgun pellet within a 15-degree spread C++
FVector AimDir = GetActorForwardVector();
FVector PelletDir = UKismetMathLibrary::RandomUnitVectorInConeInDegrees(AimDir, 15.f);
SpawnProjectile(GetMuzzleLocation(), PelletDir); See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?