RealDocs

UKismetMathLibrary::Vector2DInterpTo_Constant

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

Description

Moves a 2D position toward a target at a constant speed per second, clamping at the target when reached. Unlike Vector2DInterpTo, this does not slow down as it approaches.

Caveats & Gotchas

  • InterpSpeed here is a linear units-per-second rate, not the exponential 'feel' factor used by Vector2DInterpTo. Switching between the two requires recalibrating the speed value.
  • The result is clamped to the target when the remaining distance would be exceeded by the current step, so it will never overshoot.

Signature

static UE_INL_API FVector2D Vector2DInterpTo_Constant(FVector2D Current, FVector2D Target, float DeltaTime, float InterpSpeed);

Parameters

Name Type Description Default
Current FVector2D Current position.
Target FVector2D Target position to move toward.
DeltaTime float Time elapsed since the last frame.
InterpSpeed float Constant movement speed in units per second.

Return Type

FVector2D

Example

Move a health bar to a new value at a fixed speed C++
// Move health bar fill position 50 units per second
HealthBarFill = UKismetMathLibrary::Vector2DInterpTo_Constant(
    HealthBarFill,
    TargetFill,
    DeltaTime,
    50.f
);

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.