RealDocs

UKismetMathLibrary::RandomInteger64

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

Description

Returns a uniformly distributed random int64 in the range [0, Max). Relies on the engine's global random stream.

Caveats & Gotchas

  • Marked NotBlueprintThreadSafe — do not call from async Blueprint tasks or background threads. Use a FRandomStream on a per-actor basis for thread-safe deterministic randomness.
  • Passing Max <= 0 results in undefined behaviour in most FMath random implementations — guard that Max is positive before calling, especially when Max comes from user input or a data table.

Signature

static UE_INL_API int64 RandomInteger64(UPARAM(DisplayName = "Exclusive Max") int64 Max);

Parameters

Name Type Description Default
Max int64 Exclusive upper bound. The result is in [0, Max).

Return Type

int64

Example

Pick a random index into a large array C++
int64 ArraySize = GetLargeArraySize();
if (ArraySize > 0)
{
    int64 Index = UKismetMathLibrary::RandomInteger64(ArraySize);
    ProcessElement(Index);
}

Tags

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.