UKismetMathLibrary::RandomUnitVectorInEllipticalConeInRadiansFromStream
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns a random unit vector within a cone around ConeDir whose cross-section is an ellipse rather than a circle, letting yaw and pitch spread differ independently, drawn from a specific FRandomStream for reproducible results.
Caveats & Gotchas
- • Unlike the circular cone variant, MaxYawInRadians and MaxPitchInRadians are set independently — a common mistake is passing the same angle for both, which just reproduces the circular cone at extra cost.
- • Useful for weapon spread patterns that are wider horizontally than vertically (or vice versa); if you don't need that asymmetry, RandomUnitVectorInConeInRadiansFromStream is cheaper and simpler.
Signature
static FVector RandomUnitVectorInEllipticalConeInRadiansFromStream(const FRandomStream& Stream, const FVector& ConeDir, float MaxYawInRadians, float MaxPitchInRadians) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Stream | const FRandomStream& | The random stream from which to obtain the vector. | — |
| ConeDir | const FVector& | The base center direction of the cone. | — |
| MaxYawInRadians | float | The yaw angle of the cone, from ConeDir to its horizontal edge, in radians. | — |
| MaxPitchInRadians | float | The pitch angle of the cone, from ConeDir to its vertical edge, in radians. | — |
Return Type
FVector Example
Deterministic wide horizontal, tight vertical spread C++
FRandomStream SprayStream(WeaponSeed);
FVector Dir = UKismetMathLibrary::RandomUnitVectorInEllipticalConeInRadiansFromStream(SprayStream, AimDirection, FMath::DegreesToRadians(8.f), FMath::DegreesToRadians(2.f)); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?