USplineComponent::GetLocationAtDistanceAlongSpline
#include "Components/SplineComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableconst
Description
Returns the world or local position at a given arc-length distance along the spline, interpolated smoothly between control points.
Signature
ENGINE_API FVector GetLocationAtDistanceAlongSpline(float Distance, ESplineCoordinateSpace::Type CoordinateSpace) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Distance | float | Distance along the spline in world units, from 0 to GetSplineLength(). | — |
| CoordinateSpace | ESplineCoordinateSpace::Type | Whether to return the result in world space or local space. | — |
Return Type
FVector Caveats & Gotchas
- • Distance is arc length, not a normalised 0–1 parameter. Divide by GetSplineLength() if you want fractional progress.
- • Out-of-range distances are clamped to [0, GetSplineLength()] for open splines; for closed splines they wrap.
- • The deprecated GetWorldLocationAtDistanceAlongSpline is just a wrapper for this call with CoordinateSpace::World — prefer calling this method directly.
Example
Move an actor along the spline each tick C++
void ASplineFollower::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
CurrentDistance += Speed * DeltaTime;
if (CurrentDistance > SplineComponent->GetSplineLength())
CurrentDistance = 0.f;
FVector NewLocation = SplineComponent->GetLocationAtDistanceAlongSpline(
CurrentDistance, ESplineCoordinateSpace::World);
SetActorLocation(NewLocation);
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?