RealDocs

UKismetArrayLibrary::Array_RandomFromStream

function Engine Blueprint Since unknown
#include "Kismet/KismetArrayLibrary.h"
Access: public Specifiers: staticBlueprintPureCustomThunk

Description

Picks a random element from an array using a caller-supplied FRandomStream, producing reproducible results for a given seed.

Caveats & Gotchas

  • Unlike Array_Random, this consumes and advances the passed-in RandomStream, so the same stream used across multiple calls produces a deterministic sequence — useful for replay or seeded procedural generation.
  • If TargetArray is empty, OutIndex is set to -1 and OutItem is left at its default-constructed value; the stream is not advanced in that case.
  • Displayed in Blueprint as 'Random Array Item from Stream' with no CompactNodeTitle, distinguishing it from the CompactNodeTitle 'RANDOM' plain version.

Signature

static void Array_RandomFromStream(const TArray<int32>& TargetArray, UPARAM(Ref) FRandomStream& RandomStream, int32& OutItem, int32& OutIndex);

Parameters

Name Type Description Default
TargetArray const TArray<int32>& The array to pick from.
RandomStream UPARAM(Ref) FRandomStream& The deterministic random stream to draw from.
OutItem int32& Output parameter filled with a copy of the chosen element.
OutIndex int32& Output parameter filled with the index of the chosen element, or -1 if the array is empty.

Return Type

void

Example

Deterministic random pick C++
TArray<int32> Values = { 1, 2, 3, 4 };
FRandomStream Stream(1234);
int32 Item, Index;
UKismetArrayLibrary::Array_RandomFromStream(Values, Stream, Item, Index);
// Same seed 1234 always produces the same Item/Index

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.