Spline Helpers

Utility functions for O3DE spline queries — closest point, fraction, and local/world space conversion by entity ID.

The SplineUtility namespace (GS_Core::SplineUtility) provides free functions for querying the closest point on an O3DE spline component attached to an entity. All functions take an entity ID and a position in world or local space.

Used by: PathTo_DialoguePerformance (gs_cinematics), any system that guides an entity along a spline path.

For usage guides and setup examples, see The Basics: GS_Core.

 

Contents


API Reference

FunctionParametersDescription
FindClosestWorldPointAZ::EntityId entityId, AZ::Vector3 worldPosReturns the closest world-space point on the spline attached to entityId
FindClosestLocalPointAZ::EntityId entityId, AZ::Vector3 localPosReturns the closest point in local spline space
FindClosestFractionAZ::EntityId entityId, AZ::Vector3 worldPosReturns the normalized [0, 1] fraction along the spline of the closest point to worldPos

Usage Example

#include <GS_Core/Utility/SplineUtility.h>

// Find how far along a path the player is (0 = start, 1 = end)
AZ::Vector3 playerPos = GetPlayerWorldPosition();
float fraction = GS_Core::SplineUtility::FindClosestFraction(splineEntityId, playerPos);

// Get the actual closest world position on the path
AZ::Vector3 closestPoint = GS_Core::SplineUtility::FindClosestWorldPoint(splineEntityId, playerPos);

See Also

For related resources:


Get GS_Core

GS_Core — Explore this gem on the product page and add it to your project.