RealDocs

UKismetMathLibrary::RandomUnitVector

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

Description

Returns a random unit vector (length 1) uniformly distributed over the surface of a sphere. Useful for randomizing projectile scatter, particle burst directions, or procedural geometry.

Caveats & Gotchas

  • Marked NotBlueprintThreadSafe — calls FMath::FRand() which uses a global random state. Calling from multiple threads simultaneously causes data races and non-deterministic results.
  • Results are not reproducible between runs unless you seed the global RNG with FMath::RandInit(Seed). For deterministic or seeded sequences, use FRandomStream with RandomUnitVectorFromStream instead.

Signature

static ENGINE_API FVector RandomUnitVector();

Return Type

FVector

Example

Spawn explosion particles in random directions C++
for (int32 i = 0; i < ParticleCount; ++i)
{
    FVector Dir = UKismetMathLibrary::RandomUnitVector();
    SpawnParticle(Origin, Dir * ParticleSpeed);
}

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.