RealDocs

UKismetMathLibrary::MakeRandomStreamFromLocation

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

Description

Creates a deterministic FRandomStream whose seed is derived from a world-space location, optionally quantized to a grid. Locations within the same grid cell share an identical stream, enabling stable per-region procedural variation without storing seeds.

Caveats & Gotchas

  • When DistanceInterval > 0, every location inside the same grid cell produces the **same** stream. This is intentional for stable content, but means objects close together within one cell will draw from an identical sequence — which can look non-random if they consume values in the same order.
  • bIncludeZ defaults to false, so two points at the same XY but different altitudes produce the same seed. For 3D content such as caves, multi-floor buildings, or volumetric foliage, always set bIncludeZ=true to get independent variation per floor.

Signature

static ENGINE_API FRandomStream MakeRandomStreamFromLocation(const FVector& Location, float DistanceInterval = 200.f, bool bIncludeZ = false);

Parameters

Name Type Description Default
Location const FVector& The world-space position used to derive the stream seed.
DistanceInterval float Grid cell size in cm. All locations within the same cell share the same stream. Pass 0 to use the exact location. 200.f
bIncludeZ bool Whether the Z-coordinate contributes to the seed. False collapses all altitudes in a column to one seed. false

Return Type

FRandomStream

Example

Generate stable foliage density based on position C++
FVector TileCenter = GetTileCenter(TileX, TileY);
// All points within a 500cm grid cell share the same stream
FRandomStream Stream = UKismetMathLibrary::MakeRandomStreamFromLocation(TileCenter, 500.f, false);
int32 TreeCount = Stream.RandRange(3, 10); // consistent per tile across sessions

Version History

Introduced in: 4.15

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.