RealDocs

UKismetMathLibrary::RandomUnitVectorInEllipticalConeInRadians

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

Description

Returns a random unit vector inside an elliptical cone around ConeDir with independently controlled horizontal (yaw) and vertical (pitch) half-angles.

Caveats & Gotchas

  • MaxYaw and MaxPitch are independent half-angles, not full arc widths. Passing equal values produces a round cone equivalent to RandomUnitVectorInConeInRadians — use that simpler function instead.
  • Not thread-safe (NotBlueprintThreadSafe). The yaw/pitch axes follow ConeDir's local frame, so rotating ConeDir also rotates the ellipse orientation.

Signature

static ENGINE_API FVector RandomUnitVectorInEllipticalConeInRadians(FVector ConeDir, float MaxYawInRadians, float MaxPitchInRadians);

Parameters

Name Type Description Default
ConeDir FVector Center direction of the cone.
MaxYawInRadians float Maximum horizontal deviation from ConeDir, in radians.
MaxPitchInRadians float Maximum vertical deviation from ConeDir, in radians.

Return Type

FVector

Example

Simulate wide-horizontal, narrow-vertical weapon spread C++
FVector AimDir = GetActorForwardVector();
float HYaw   = FMath::DegreesToRadians(20.f);
float HPitch = FMath::DegreesToRadians(5.f);
FVector ShotDir = UKismetMathLibrary::RandomUnitVectorInEllipticalConeInRadians(
    AimDir, HYaw, HPitch);

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.