UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FRandomStream Struct Reference

#include <RandomStream.h>

Public Member Functions

 FRandomStream ()
 
 FRandomStream (int32 InSeed)
 
 FRandomStream (FName InName)
 
void Initialize (int32 InSeed)
 
void Initialize (FName InName)
 
void Reset () const
 
int32 GetInitialSeed () const
 
void GenerateNewSeed ()
 
float GetFraction () const
 
uint32 GetUnsignedInt () const
 
FVector GetUnitVector () const
 
int32 GetCurrentSeed () const
 
UE_FORCEINLINE_HINT float FRand () const
 
UE_FORCEINLINE_HINT int32 RandHelper (int32 A) const
 
int32 RandRange (int32 Min, int32 Max) const
 
UE_FORCEINLINE_HINT FVector::FReal FRandRange (FVector::FReal InMin, FVector::FReal InMax) const
 
UE_FORCEINLINE_HINT FVector VRand () const
 
FVector RandPointInBox (const FBox &Box) const
 
FVector VRandCone (FVector const &Dir, float ConeHalfAngleRad) const
 
FVector VRandCone (FVector const &Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad) const
 
FString ToString () const
 

Protected Member Functions

void MutateSeed () const
 

Friends

struct Z_Construct_UScriptStruct_FRandomStream_Statics
 

Detailed Description

Implements a thread-safe SRand based RNG.

Very bad quality in the lower bits. Don't use the modulus (%) operator.

Constructor & Destructor Documentation

◆ FRandomStream() [1/3]

FRandomStream::FRandomStream ( )
inline

Default constructor.

The seed should be set prior to use.

◆ FRandomStream() [2/3]

FRandomStream::FRandomStream ( int32  InSeed)
inline

Creates and initializes a new random stream from the specified seed value.

Parameters
InSeedThe seed value.

◆ FRandomStream() [3/3]

FRandomStream::FRandomStream ( FName  InName)
inline

Creates and initializes a new random stream from the specified name.

Note
If NAME_None is provided, the stream will be seeded using the current time.
Parameters
InNameThe name value from which the stream will be initialized.

Member Function Documentation

◆ FRand()

UE_FORCEINLINE_HINT float FRandomStream::FRand ( ) const
inline

Mirrors the random number API in FMath

Returns
Random number.

◆ FRandRange()

UE_FORCEINLINE_HINT FVector::FReal FRandomStream::FRandRange ( FVector::FReal  InMin,
FVector::FReal  InMax 
) const
inline

Helper function for rand implementations.

Returns
A random number >= Min and <= Max

◆ GenerateNewSeed()

void FRandomStream::GenerateNewSeed ( )
inline

Generates a new random seed.

◆ GetCurrentSeed()

int32 FRandomStream::GetCurrentSeed ( ) const
inline

Gets the current seed.

Returns
Current seed.

◆ GetFraction()

float FRandomStream::GetFraction ( ) const
inline

Returns a random float number in the range [0, 1).

Returns
Random number.

◆ GetInitialSeed()

int32 FRandomStream::GetInitialSeed ( ) const
inline

◆ GetUnitVector()

FVector FRandomStream::GetUnitVector ( ) const
inline

Returns a random vector of unit size.

Returns
Random unit vector.

◆ GetUnsignedInt()

uint32 FRandomStream::GetUnsignedInt ( ) const
inline

Returns a random number between 0 and MAXUINT.

Returns
Random number.

◆ Initialize() [1/2]

void FRandomStream::Initialize ( FName  InName)
inline

Initializes this random stream using the specified name.

Note
If NAME_None is provided, the stream will be seeded using the current time.
Parameters
InNameThe name value from which the stream will be initialized.

◆ Initialize() [2/2]

void FRandomStream::Initialize ( int32  InSeed)
inline

Initializes this random stream with the specified seed value.

Parameters
InSeedThe seed value.

◆ MutateSeed()

void FRandomStream::MutateSeed ( ) const
inlineprotected

Mutates the current seed into the next seed.

◆ RandHelper()

UE_FORCEINLINE_HINT int32 FRandomStream::RandHelper ( int32  A) const
inline

Helper function for rand implementations.

Returns
A random number in [0..A)

◆ RandPointInBox()

FVector FRandomStream::RandPointInBox ( const FBox Box) const
inline

◆ RandRange()

int32 FRandomStream::RandRange ( int32  Min,
int32  Max 
) const
inline

Helper function for rand implementations.

Returns
A random number >= Min and <= Max

◆ Reset()

void FRandomStream::Reset ( ) const
inline

Resets this random stream to the initial seed value.

◆ ToString()

FString FRandomStream::ToString ( ) const
inline

Get a textual representation of the RandomStream.

Returns
Text describing the RandomStream.

◆ VRand()

UE_FORCEINLINE_HINT FVector FRandomStream::VRand ( ) const
inline

Returns a random vector of unit size.

Returns
Random unit vector.

◆ VRandCone() [1/2]

FVector FRandomStream::VRandCone ( FVector const &  Dir,
float  ConeHalfAngleRad 
) const
inline

Returns a random unit vector, uniformly distributed, within the specified cone.

Parameters
DirThe center direction of the cone
ConeHalfAngleRadHalf-angle of cone, in radians.
Returns
Normalized vector within the specified cone.

◆ VRandCone() [2/2]

FVector FRandomStream::VRandCone ( FVector const &  Dir,
float  HorizontalConeHalfAngleRad,
float  VerticalConeHalfAngleRad 
) const
inline

Returns a random unit vector, uniformly distributed, within the specified cone.

Parameters
DirThe center direction of the cone
HorizontalConeHalfAngleRadHorizontal half-angle of cone, in radians.
VerticalConeHalfAngleRadVertical half-angle of cone, in radians.
Returns
Normalized vector within the specified cone.

Friends And Related Symbol Documentation

◆ Z_Construct_UScriptStruct_FRandomStream_Statics

friend struct Z_Construct_UScriptStruct_FRandomStream_Statics
friend

The documentation for this struct was generated from the following file: