UKismetMathLibrary::Vector2DInterpTo
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Smoothly moves a 2D position toward a target using exponential interpolation. Produces a spring-like ease-out that slows as it approaches the target.
Caveats & Gotchas
- • The interpolation is frame-rate dependent in that it uses DeltaTime directly. Unlike FMath::Lerp, passing a large DeltaTime can overshoot the target; the function internally clamps to prevent this.
- • Setting InterpSpeed to 0 causes an immediate snap to Target regardless of DeltaTime.
Signature
static UE_INL_API FVector2D Vector2DInterpTo(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 | Interpolation speed; 0 snaps instantly to the target. | — |
Return Type
FVector2D Example
Smoothly follow a UI cursor toward mouse position C++
// In Tick or TickComponent
CursorPosition = UKismetMathLibrary::Vector2DInterpTo(
CursorPosition,
TargetMousePosition,
DeltaTime,
8.f
); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?