RealDocs

UKismetMathLibrary::RandomRotator

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

Description

Generates a uniformly random rotation in Pitch [-90, 90] and Yaw [-180, 180]. Roll is randomized in [-180, 180] only when bRoll is true.

Caveats & Gotchas

  • This function is marked NotBlueprintThreadSafe — do not call it from parallel async tasks or Animation Graph threads. Use RandomRotatorFromStream with a seeded FRandomStream for thread-safe or deterministic random rotations.
  • The distribution is uniform over Euler angles, not uniform over SO(3) (rotation group). For physically unbiased random orientations, generate a random quaternion (e.g. from a uniform unit-hypersphere sample) instead.

Signature

static ENGINE_API FRotator RandomRotator(bool bRoll = false);

Parameters

Name Type Description Default
bRoll bool If true, the Roll component is also randomized. If false, Roll is 0. false

Return Type

FRotator

Example

Scatter spawned debris in random orientations C++
for (int32 i = 0; i < 10; ++i)
{
	FRotator RandRot = UKismetMathLibrary::RandomRotator(/*bRoll=*/true);
	World->SpawnActor<ADebrisPiece>(SpawnLocation, RandRot);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.