USplineComponent::GetDirectionAtDistanceAlongSpline
#include "Components/SplineComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableconst
Description
Returns a unit direction vector tangent to the spline at the given arc-length distance. Use this to orient a following actor so it faces along the spline.
Signature
ENGINE_API FVector GetDirectionAtDistanceAlongSpline(float Distance, ESplineCoordinateSpace::Type CoordinateSpace) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Distance | float | Arc-length distance along the spline from 0 to GetSplineLength(). | — |
| CoordinateSpace | ESplineCoordinateSpace::Type | Whether to return the result in world space or local space. | — |
Return Type
FVector Caveats & Gotchas
- • The returned vector is unit length. If you need the raw (unscaled) tangent, use GetTangentAtDistanceAlongSpline instead.
- • On very sharp bends or degenerate segments, the direction can change abruptly. Smooth the result if you're driving rotation from it.
Example
Orient a follower to face along the spline C++
FVector Direction = SplineComponent->GetDirectionAtDistanceAlongSpline(
CurrentDistance, ESplineCoordinateSpace::World);
SetActorRotation(Direction.Rotation()); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?