RealDocs

UKismetMathLibrary::RandomBool

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

Description

Returns a uniformly distributed random boolean — roughly 50/50 true or false on each call. Uses the engine's global random stream, which is not reproducible across runs unless the seed is set.

Caveats & Gotchas

  • Marked NotBlueprintThreadSafe — do not call from Blueprint async nodes or C++ parallel-for loops; use RandomBoolWithWeightFromStream with a per-thread FRandomStream instead.
  • The underlying global RNG is shared across the engine; other systems (physics, AI, etc.) consuming random numbers will shift the sequence and alter results if call order changes.

Signature

static UE_INL_API bool RandomBool();

Return Type

bool

Example

Randomly flip a coin at game start C++
bool bHeads = UKismetMathLibrary::RandomBool();
UE_LOG(LogGame, Log, TEXT("Coin flip: %s"), bHeads ? TEXT("Heads") : TEXT("Tails"));

Tags

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.