RealDocs

UKismetMathLibrary::RandomUnitVectorInConeInDegreesFromStream

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

Description

Returns a random unit vector uniformly distributed within a cone around ConeDir, drawn from a specific FRandomStream. This is a degrees-based inline convenience wrapper around RandomUnitVectorInConeInRadiansFromStream.

Caveats & Gotchas

  • Defined inline in the header as a thin wrapper that converts degrees to radians and forwards to RandomUnitVectorInConeInRadiansFromStream — prefer the radians version directly in hot code paths that already work in radians to avoid the extra conversion.
  • Same zero-half-angle behaviour as the radians version: a half-angle of 0 or less returns ConeDir unchanged rather than randomizing.

Signature

static FVector RandomUnitVectorInConeInDegreesFromStream(const FRandomStream& Stream, const FVector& ConeDir, float ConeHalfAngleInDegrees)

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.
ConeHalfAngleInDegrees float The half-angle of the cone, from ConeDir to its edge, in degrees.

Return Type

FVector

Example

Deterministic scatter using degrees C++
FRandomStream SprayStream(WeaponSeed);
FVector SprayDir = UKismetMathLibrary::RandomUnitVectorInConeInDegreesFromStream(SprayStream, AimDirection, 3.5f);

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.