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.

This is actually helpful since this is gonna be the next step.

I was gonna update this after I had finished working on it a bit more but this is probably a good time to start.

As for generating a spline. I my case is special, I used the projectile projection node. This will not apply for everyone but it gives you path nodes. Then just “For Each” (NOT FOR EACH LOOP!) This will give me what I’m looking for.


For actually effective making the end points bend. I used a Offset Vector. This takes in outside information and basically gets a flat value (Example: 0, 50, 0) and pulls the end point to that and then bends it by dividing the the current index versus the maximum index to cause this blend to happen smoothly and have zero effect over the first point.

here’s a screen shot

[1]Ignore the Power node. For me this was to make it bend lightly in the beginning but much later on.

This should explain Generally how to make this offset work


  1. Footnotes ↩︎