UKismetMathLibrary::RandomIntegerInRange
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns a random integer in the inclusive range [Min, Max]. Both bounds are included in the possible output.
Caveats & Gotchas
- • Unlike RandomInteger, both Min and Max are inclusive. Passing Min == Max returns Min every time without asserting — useful to know but easy to misuse.
- • Like RandomInteger, this is NotBlueprintThreadSafe due to shared global RNG state. Avoid calling from worker threads; use FRandomStream for deterministic or thread-safe randomness.
Signature
static UE_INL_API int32 RandomIntegerInRange(int32 Min, int32 Max); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Min | int32 | Inclusive lower bound. | — |
| Max | int32 | Inclusive upper bound. | — |
Return Type
int32 Example
Roll a six-sided die C++
int32 DieResult = UKismetMathLibrary::RandomIntegerInRange(1, 6);
UE_LOG(LogTemp, Log, TEXT("Rolled: %d"), DieResult); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?