Hi. I have just updated my UE from 5.0 to 5.2. And my timelines in C++ code stopped working. Here is my code:
URecoil::URecoil()
{
// Create recoil timeline
m_timeline = CreateDefaultSubobject<UTimelineComponent>("RecoilTimeline");
// Yaw curve
m_yawCurve = CreateDefaultSubobject<UCurveFloat>("YawCurve");
FOnTimelineFloat yawCallback;
yawCallback.BindUFunction(this, "yawCallback");
m_timeline->AddInterpFloat(m_yawCurve, yawCallback);
// Pitch curve
m_pitchCurve = CreateDefaultSubobject<UCurveFloat>("PitchCurve");
FOnTimelineFloat pitchCallback;
pitchCallback.BindUFunction(this, "pitchCallback");
m_timeline->AddInterpFloat(m_pitchCurve, pitchCallback);
}
...
void URecoil::start(const FRichCurve &yawCurve, const FRichCurve &pitchCurve)
{
if (!m_receiver)
return;
// Configure curves
m_yawCurve->FloatCurve = yawCurve;
m_pitchCurve->FloatCurve = pitchCurve;
// Start timeline
m_timeline->PlayFromStart();
}
Curves are created in other code. Example:
FRichCurve yaw;
yaw.SetKeyInterpMode(yaw.AddKey(0.0f, 0.0f), ERichCurveInterpMode::RCIM_Cubic);
yaw.SetKeyInterpMode(yaw.AddKey(RECOIL_TIME, FMath::FRandRange(0.3f, 0.4f)), ERichCurveInterpMode::RCIM_Cubic);
This code worked fine in 5.0. But now I see that callback functions yawCallback and pitchCallback are called twice with zero values.
Any ideas how to fix it? Timelines with curves from content browser work good.