RealDocs

UKismetMathLibrary::RandomIntegerFromStream

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

Description

Returns a uniformly distributed random integer between 0 and Max - 1, drawn from a specific FRandomStream instead of the engine's global RNG, so the sequence is deterministic and reproducible from a known seed.

Caveats & Gotchas

  • Stream is a const reference but its internal Seed field is mutable, so every call still advances the stream's sequence even though the parameter isn't passed by UPARAM(ref) — the const-ness only protects against reassigning the stream itself.
  • Passing Max <= 0 returns 0 rather than asserting or erroring, so guard against a zero or negative range yourself if that would be a logic bug.

Signature

static int32 RandomIntegerFromStream(const FRandomStream& Stream, int32 Max)

Parameters

Name Type Description Default
Stream const FRandomStream& The random stream to draw from.
Max int32 Exclusive upper bound; the result is in the range [0, Max - 1].

Return Type

int32

Example

Deterministic loot roll C++
FRandomStream LootStream(Seed);
int32 LootIndex = UKismetMathLibrary::RandomIntegerFromStream(LootStream, LootTable.Num());

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.