Spline Components through c++

I want to spawn Spline Components dynamically in game through c++… I couldn’t find much documentation on how to do so through c++.

Where should i start looking for it.

Hey there!

I used it as an UPROPERTY in my custom Actor Class like this:

	/**Spline component*/
	UPROPERTY(EditAnywhere, Category = YourCategory)
		TSubobjectPtr<class USplineComponent> YourSplineComponent;

After that you can Initialize it like this in your cpp

YourSplineComponent = PCIP.CreateDefaultSubobject<USplineComponent>(this, TEXT("YourSplineComponent"));

You also need to add SplineComponent.h its #include "Classes/Components/SplineComponent.h" on 4.6

After that you should look the properties of the object, if you wanna add points for example something like this:

for(int i = 0; i < Points.Num(); i++)
	{
		SplineComp->AddSplineLocalPoint(Points[i]);
	}

I hope it helps!

Anyone knows how to do this in 4.7.2? The TSubobjectPtr is deprecated so my propery looks like this:

	UPROPERTY(EditAnywhere, Instanced, Category = "Path spline")
	USplineComponent* PathSpline;

And it is initiate in the constructor like so:

PathSpline = CreateDefaultSubobject<USplineComponent>(TEXT("Path"));

But why cant I add additional spline path nodes in the editor?

Is there any documentation on using splines in c++?

Im so sorry for the late reply, i leave my project and take it back like 3 weeks ago or so, i started again in 4.10, i needed some time to know how can i access nicely to the components in the editor.

To create them:

UPROPERTY(properties stuff)
class USplineComponent* PathSpline;

In the init function of the class AYourClass::AYourClass use the PCIP initializer, so PathSpline = PCIP.CreateDefaultSubobject(FName("Name"));

If you cant edit it, them try to add this after you attached it to the Parent that you want and so on, PathSpline->bSplineHasBeenEdited = true;

Hope it helps!