So then while looping through you UActorComponent objects from this TArray You can just do:
for (auto ActorComp : ActorComponentsArray)
{
auto* SplineComp = Cast<USplineComponent>(ActorComp);
// do sth with SplineComp, but check it's validity first
}
Splines are so annoying in Unreal Engine, I don’t know why!
They just make it overly complicated to get a spline object.
Epic:
Can we have an intuitive spline struct, which has helper functions for getting the transform along a spline, getting spline points at index, ect. I know this can be done with the spline component, but not with the underlying data struct FSpineCurves. This is really annoying because sometimes you need an array of Splines or you want to store splines in a data asset. The only workaround I’ve seen is to literally dynamically create a spline component to just access these simple features, or preallocate a spline component and then feed it different spline curves, non of these are easy or intuitive.
IMO it’s such an min/maxing that it is neglible for the most part in code. Depend’s how far You want to go with optimisation but other stuff in game will be of more struggle than this.