Beispiel #1
0
        /// <summary>
        /// Interpolate Linear Color from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.
        /// </summary>
        public static FLinearColor CInterpTo(FLinearColor current, FLinearColor target, float deltaTime, float interpSpeed)
        {
            // If no interp speed, jump to target value
            if (interpSpeed <= 0.0f)
            {
                return(target);
            }

            // Difference between colors
            float dist = FLinearColor.Dist(target, current);

            // If distance is too small, just set the desired color
            if (dist < KindaSmallNumber)
            {
                return(target);
            }

            // Delta change, Clamp so we do not over shoot.
            FLinearColor deltaMove = (target - current) * FMath.Clamp(deltaTime * interpSpeed, 0.0f, 1.0f);

            return(current + deltaMove);
        }