I am trying to recreate the blueprint spline track example in C++. In the Blueprint there is a ‘Add Spline Mesh Component’ call and I am not sure how I would translate this to C++.
I tried
void Foo::OnConstruction(const FTransform& Transform)
{
int32 SplinePoints = Spline->GetNumSplinePoints();
for (int32 i = 0; i < SplinePoints; ++i){
FVector Location, Tangent;
Spline->GetLocalLocationAndTangentAtSplinePoint(i, Location, Tangent);
USplineMeshComponent *s = CreateDefaultSubobject<USplineMeshComponent>(TEXT(""));
...
}
}
but this crashes the editor. I just want to spawn a SplineMeshComponent in the construction script, how would I do that?