UKismetMathLibrary::LinearColorLerp
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Linearly interpolates between two linear colors channel-by-channel. Alpha=0 returns A, Alpha=1 returns B.
Caveats & Gotchas
- • Alpha is not clamped — values outside [0,1] will extrapolate beyond A or B, potentially producing negative channel values or values above 1.
- • Blending in linear RGB can produce a desaturated midpoint for complementary colors (e.g. red↔cyan passes through grey). Use LinearColorLerpUsingHSV to preserve saturation during large hue transitions.
Signature
static UE_INL_API FLinearColor LinearColorLerp(FLinearColor A, FLinearColor B, float Alpha); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FLinearColor | Start color (returned when Alpha=0). | — |
| B | FLinearColor | End color (returned when Alpha=1). | — |
| Alpha | float | Blend factor in [0,1]. | — |
Return Type
FLinearColor Example
Blend two colors by a gameplay variable C++
float HealthPercent = CurrentHealth / MaxHealth;
FLinearColor DisplayColor = UKismetMathLibrary::LinearColorLerp(
FLinearColor::Red,
FLinearColor::Green,
HealthPercent
);
HealthBarMaterial->SetVectorParameterValue(TEXT("Color"), DisplayColor); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?