Spline auto Projection

TL:DR I’m trying to auto generate a spline curve based on a math equation.

I’ve made a few versions of this but it’s just not exactly what I’m looking for or is just way to complicated and messy.

  1. ON construction: Create a start point and end point in the spline
  2. Create a curve from those two points in the spline
  3. Store this spline curve for later use
  4. Allow adjustments without recalculation (making the curve go off to the left for example)

that’s it really. This isn’t really an area I mess around with much so I’m kinda scratching my head more than I should. Any help is appreciated.

as for the math equation of how the curve should be, it’s irrelevant and can be place holder numbers for now. It’s the actually spline generation I’m struggling with

We sub-classed the USplineComponent class and added this simplified function to add a spline point. This should get you started.

void UBaseSplineComponent::AddSplinePoint(FVector location, FRotator rotation)
{
	// calculate key which is the number of points currently
	// create spline point and add to the spline
	float inputKey = (float)GetNumberOfSplinePoints();
	FSplinePoint newSplinePoint = FSplinePoint(inputKey, location, ESplinePointType::Curve, rotation);
	AddPoint(newSplinePoint);
}

You just need to create an FSplinePoint struct and add it. To regenerate we usually just ClearSplinePoints() and then re-add them all. But we aren’t using huge splines that get updated every frame.