UKismetMathLibrary::LinearColor_SetRandomHue
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Chooses a random hue and writes a visually pleasing fully-saturated color into the target LinearColor. The saturation and value are fixed to produce a vivid, non-grey result rather than a uniform random RGB triple.
Caveats & Gotchas
- • The hue is the only randomized component — saturation and value are fixed, so the output will always be a bright, saturated color. You cannot use this to generate pastel or dark random colors.
- • Uses UE's global FMath::FRand() stream, which is not seeded per-call. Results are non-deterministic and will differ between play sessions and between PIE and packaged builds unless you seed the global random before use.
Signature
static UE_INL_API void LinearColor_SetRandomHue(UPARAM(ref) FLinearColor& InOutColor) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOutColor | FLinearColor& | The color variable to overwrite with a randomly hued color. | — |
Return Type
void Example
Assign a random vivid color to each spawned actor C++
FLinearColor RandomColor;
UKismetMathLibrary::LinearColor_SetRandomHue(RandomColor);
SpawnedMesh->SetVectorParameterValueOnMaterials(TEXT("Color"), FVector(RandomColor)); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?