RealDocs

UKismetMathLibrary::RandomFloat

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

Description

Returns a random float in the range [0, 1] using the global random stream. Not suitable for seeded/deterministic use cases.

Caveats & Gotchas

  • Marked NotBlueprintThreadSafe — calling this from a Blueprint async task or a background thread will assert in debug builds and produce data races in shipping builds; use FRandomStream for thread-safe randomness.
  • Uses a global FMath random seed; for gameplay systems that need reproducible randomness (replays, seeds-based level generation) use FRandomStream with an explicit seed instead.

Signature

static UE_INL_API double RandomFloat();

Return Type

double

Example

Random spawn jitter C++
FVector SpawnLocation = BaseLocation;
SpawnLocation.X += (UKismetMathLibrary::RandomFloat() - 0.5) * 200.0;
SpawnLocation.Y += (UKismetMathLibrary::RandomFloat() - 0.5) * 200.0;

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.