How to get a Random Number in range c++?

The only thing i was able to find is FMath::RangRange, but im not sure how to use it

The kismet Library is just there to expose FMath::FRandRange to Blueprint.

The C++ way of using Random Number is:

#include "Math/UnrealMathUtility.h"

const int32 Min = 10;
const int32 Max = 50;
const int32 RandomInt = FMath::RandRange(Min, Max);

The type of Min and Max determines what type you get returned for example float, double, int32 etc.

And with RandomStream

#include "Math/RandomStream.h"

const int32 Seed= 1;
const FRandomStream RandomStream(Seed);
const int32 Min = 10;
const int32 Max = 50;
const int32 RandomInt = RandomStream.RandRange(Min,Max);
1 Like