RealDocs

UKismetMathLibrary::LinearColor_IsNearEqual

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

Description

Returns true if every channel of A and B differ by no more than Tolerance. Prefer this over EqualEqual_LinearColorLinearColor whenever the colors may have been derived from floating-point arithmetic.

Caveats & Gotchas

  • The tolerance is applied per channel independently, not as a total Euclidean distance — two colors can pass this test while still having a visually noticeable difference if all four channels are near the tolerance boundary simultaneously.
  • The default tolerance of 1e-4 is very tight; for colors produced by multiple arithmetic operations, consider widening to 1e-3 or more.

Signature

static UE_INL_API bool LinearColor_IsNearEqual(FLinearColor A, FLinearColor B, float Tolerance = 1.e-4f);

Parameters

Name Type Description Default
A FLinearColor First color.
B FLinearColor Second color.
Tolerance float Per-channel absolute tolerance for the comparison. 1.e-4f

Return Type

bool

Example

Guard against floating-point drift after color math C++
FLinearColor Computed = /* result of several lerps */;
FLinearColor Expected = FLinearColor::White;
if (UKismetMathLibrary::LinearColor_IsNearEqual(Computed, Expected, 0.01f))
{
    // Close enough to white
}

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.