RealDocs

UKismetMathLibrary::RandomUnitVectorFromStream

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

Description

Returns a random vector of length 1.0, uniformly distributed over the unit sphere, drawn from a specific FRandomStream for reproducible results.

Caveats & Gotchas

  • Uses a rejection-sampling loop internally (FRandomStream::GetUnitVector), so it consumes a variable, unpredictable number of draws from the stream — do not assume it always advances the stream by a fixed amount.
  • For deterministic replay across a network match, all clients and the server must construct their FRandomStream with the same seed and call this in the same order, or results will diverge.

Signature

static FVector RandomUnitVectorFromStream(const FRandomStream& Stream)

Parameters

Name Type Description Default
Stream const FRandomStream& The random stream to draw from.

Return Type

FVector

Example

Deterministic explosion debris direction C++
FRandomStream DebrisStream(ExplosionSeed);
FVector Direction = UKismetMathLibrary::RandomUnitVectorFromStream(DebrisStream);

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.