RealDocs

UKismetMathLibrary::RandomBoolFromStream

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

Description

Returns a random boolean with roughly a 50/50 chance, drawn from a specific FRandomStream for deterministic results.

Caveats & Gotchas

  • There is no weighted variant of this stream function — use RandomFloatFromStream against a threshold if you need an uneven probability.
  • As with the other FromStream functions, calls must happen in the same order across runs to reproduce the same sequence of results.

Signature

static bool RandomBoolFromStream(const FRandomStream& Stream)

Parameters

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

Return Type

bool

Example

Deterministic coin flip for a seeded encounter C++
FRandomStream EncounterStream(Seed);
bool bAmbush = UKismetMathLibrary::RandomBoolFromStream(EncounterStream);

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.