Interpolation Between Miltiple Locations

Hello.
First I’d like to mention that I use C++ only, so make no blueprint based answers, please.
I need to smoothen trajectory between multiple points (5 in my case) so I can take FRotator (angle) in any place of that graph. I know, it doesn’t sound very clear, so take a look at an example picture below.

I need my character to change his head rotation so his head follows that line (only in rotation), based on the third value.
So I need to smoothen the graph from the picture and be able to take rotation (‘lookAt’ rotation) in any place of the graph.

I’ve already tried Lerp(), but it didn’t work well for me, so I need something more complicated.

There is the template FInterpCurve class ( FInterpCurve | Unreal Engine Documentation ) with various template instances, e.g. for vectors. So you can just add your points into this curve with AddPoint(). Then for a smooth curve you have to iterate over the Points variable and set each point’s InterpMode to CIM_CurveAuto, which overrides the default CIM_Linear. And then simply call the Eval() function from your curve.

Well… like your question suggests, try interpolate? (FInterpTo() in c++)

Thank you very much.
I am trying to use it, but for some reason, I can’t get the header file to be included.
According to documentation the header is in
“Runtime/Core/Public/Math/InterpCurve.h”, but classname is still undefined.

These are actually two problems described, but which one is it? Is the compiler unable to find the header or is the classname undefined? Perhaps some sourcecode and compiler output can help?

Okay, so your compiler found the header. Try using FInterpCurveVector, which is (I assume?) the same as FInterpCurve with an Vector as argument list. But better use FInterpCurveVector.

EDIT: Update because of markup problems, sorry :smiley:

Oh! Sorry being unclear about that.
It is actually a very specific problem because Error List says
“argument list for class template “FInterpCurve” is missing”.

Thank you for your solution and support.
I will try to implement it tomorrow and see if it solves my problem.
:slight_smile:

Yes, I think it works for me. Although, I am still tweaking it a lot, so maybe I’ll switch to something else in the future.
I also got another problem, but this probably is a different topic.
Thank you a lot!