The Unreal math library provides support for linear interpolation of values via the FMath::Lerp method. That works great with many built-in types, but doesn’t know how to deal with custom data types:
A solution could be to manually call FMath::Lerp on each member, or add a static Lerp method to the structure, but personally I’d prefer to use FMath::Lerp directly as I find it more readable and consistent.
TCustomLerp is a new templated helper in UE5 that can be specialized for any type we want to interpolate:
TCustomLerp is also used internally by the engine to make FMath::Lerp support types for which interpolation is non-trivial (such as FRotator and FQuat).
Bonus: lerp any engine struct
TCustomLerp can be used for any data type, including built-in ones such as FMargin that aren’t supported by FMath::Lerp out-of-the-box:
Bonus 2: BiLerp and CubicInterp
FMath::BiLerp and FMath::CubicInterp are also supported: