How to use add a component during runtime, NOT in Constructor

Hello I’m trying to add a spline component to my actor class and its not suppose to occur in the constructor but during runtime in a function/method I made for updating an arc spline… I’m having trouble with how to write for it and the documentation doesn’t have an example that I can find or in the forums, or anywhere really.

where I’m at in the method for anybody wondering what I mean:

void AVRMotionController::UpdateArcSpline(bool FoundValidLocation, TArray<FVector> SplinePoints)
{
	if (!FoundValidLocation)
	{
		SplinePoints.Empty();
		SplinePoints.Add(ArcDirection->GetComponentLocation());
		SplinePoints.Add((ArcDirection->GetForwardVector() * 20.0f) + ArcDirection->GetComponentLocation());
	}

	for (FVector Thing : SplinePoints)
	{
		ArcSpline->AddSplinePoint(Thing, ESplineCoordinateSpace::Local, true);
	}

	ArcSpline->SetSplinePointType(SplinePoints.Last, ESplinePointType::CurveClamped, true);

	for (int index = 0; index < ArcSpline->GetNumberOfSplinePoints - 2; index++)
	{
		//AddComponent(FName("splineMesh"), true, RootComponent->GetRelativeTransform,)
	}
}

I found a solution to what I was asking for, here’s a link to what I mean for general purposes: Thanks Rama!

For those wondering what my code is:

USplineMeshComponent* newSpline;

		newSpline = ConstructObject<USplineMeshComponent>(USplineMeshComponent::StaticClass(), this, TEXT("newSpline"));
		newSpline->RegisterComponent();
		newSpline->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
		newSpline->SetRelativeRotation(FRotator(0.0f, 0.0f, 0.0f));
		newSpline->AttachTo(Scene,TEXT("NAME_None"),EAttachLocation::SnapToTarget);