UKismetMathLibrary::RandomPointInBoundingBox
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns a uniformly random point inside an axis-aligned bounding box defined by a center and per-axis half-extents. Commonly used to scatter spawns within a region.
Caveats & Gotchas
- • HalfSize is the half-extent, not the full box dimensions — a common off-by-factor-of-two bug. UBoxComponent::GetScaledBoxExtent() already returns half-extents, so pair them directly.
- • Not thread-safe (NotBlueprintThreadSafe); shares the global FMath random state with all other non-stream random functions.
Signature
static UE_INL_API FVector RandomPointInBoundingBox(const FVector Center, const FVector HalfSize); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Center | FVector | Center of the bounding box. | — |
| HalfSize | FVector | Half-extents of the box (radius per axis, not full width). | — |
Return Type
FVector Example
Scatter item spawns inside a room volume C++
FVector RoomCenter = RoomBox->GetComponentLocation();
FVector HalfExtent = RoomBox->GetScaledBoxExtent();
FVector SpawnPos = UKismetMathLibrary::RandomPointInBoundingBox(RoomCenter, HalfExtent);
SpawnItem(SpawnPos); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?