Timeline Tracks in C++

.h file:

FTimeline AimTimeLine = FTimeline();
UCurveFloat* AimCurve;
void TimeLineFloat(float Value);

.cpp file:

ConstructorHelpers::FObjectFinder<UCurveFloat> FloatCurve(TEXT(“CurveFloat’/Game/StrandedExtras/Curves/AimCurve.AimCurve’”));
AimCurve = FloatCurve.Object;
FOnTimelineFloat TimeLineFunction;
TimeLineFunction.BindUFunction(this, FName{ TEXT(“TimeLineFloat”) });
AimTimeLine.AddInterpFloat(AimCurve, TimeLineFunction, FName{ TEXT(“Float Alpha”) });

void AStrandedCharacter::BeginAim()
{
AimTimeLine.Play();
FollowCamera->FieldOfView = FMath::Lerp(70, 90, AimTimeLine.GetPlaybackPosition());
}

This is my code and I made my float track and created the Timeline and now I want to use the created float timeline for my Alpha in the Lerp, but I have no idea how to get the float track that I created. Also if there is anything wrong with the code could you please help? Thanks

I would recommend using the timeline component, sadly I never got it to work with FTimeline. This tutorial should give you the right setup https://wiki.unrealengine.com/Timeline_in_c%2B%2B

If you worked with BluePrints before, I would also recommend naming the tutorials “TimelineFloatReturn” to “Update”, since that’s the function you were using in BP’s.
Cheers <3

I hope someone will see this without creating new thread ,I can load curve via



                UPROPERTY(Category = SPF, EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
		class UCurveLinearColor* CurvLC;


but I have problem with loading Curves when I want to be hard coded with ConstructorHelpers::FObjectFinder in UE 4.16.2



        static ConstructorHelpers::FObjectFinder<UCurveLinearColor>CurveLC(TEXT("CurveLinearColor'/Game/CurveLC.CurveLC'"));
	CurvLC = CurveLC.Object; 
 

give me error:
CompilerResultsLog:Error: Error f:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\CoreUObject\Public\UObject/ConstructorHelpers.h(109) : error C2664: ‘void ConstructorHelpers::ValidateObject(UObject *,const FString &,const TCHAR *)’: cannot convert argument 1 from ‘UCurveLinearColor *’ to ‘UObject *’
CompilerResultsLog:Error: Error f:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\CoreUObject\Public\UObject/ConstructorHelpers.h(109) : note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
CompilerResultsLog:Error: Error f:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\CoreUObject\Public\UObject/ConstructorHelpers.h(102) : note: while compiling class template member function ‘ConstructorHelpers::FObjectFinder<UCurveLinearColor>::FObjectFinder(const TCHAR *)’
CompilerResultsLog:Error: Error f:\Unreal Projects\CppSPF\Source\CppSPF\Cp.cpp(27) : note: see reference to function template instantiation ‘ConstructorHelpers::FObjectFinder<UCurveLinearColor>::FObjectFinder(const TCHAR *)’ being compiled
CompilerResultsLog:Error: Error f:\Unreal Projects\CppSPF\Source\CppSPF\Cp.cpp(27) : note: see reference to class template instantiation ‘ConstructorHelpers::FObjectFinder<UCurveLinearColor>’ being compiled

I included

#include “UObject/ConstructorHelpers.h”
#include “Kismet/GameplayStatics.h”

In 4.14 and 4.15 worked fine

Thx in advance

#include “Curves/CurveLinearColor.h”

and now it’s working