Use several curves with one Timeline in C++

Hi,

I’m trying to use three UCurvesFloat in one FTimeline, but i can’t managed to do the same things as the blueprint.
126553-sample.png

I don’t know why in my code the first curves is correctly set and i can use it but the two others are either 0 or NAN. I’ve checked the curves are correctly loaded.

Here is how i init my Timeline:


FOnTimelineEvent SizeChangeEnd= FOnTimelineEvent();
	SizeChangeEnd.BindUFunction(this, FName("SizeChangeEnd"));
	progressFunction.BindUFunction(this, "UpdateSize");
	static ConstructorHelpers::FObjectFinder<UCurveFloat> Curvy(TEXT("/Game/_Rescale/_Blueprints/AnimationCurves/Anim_CubeInteractableSwitch"));
	if (Curvy.Object != NULL) {
		SwitchInteracAlpha = Curvy.Object;
	}
	else {
		UE_LOG(LogTemp, Warning, TEXT("Null"));
	}
	TScaleTransition.AddInterpFloat(SwitchInteracAlpha, progressFunction, FName("InteracAlpha"), FName("InteracAlpha"));
	static ConstructorHelpers::FObjectFinder<UCurveFloat> Curvy3(TEXT("/Game/_Rescale/_Blueprints/AnimationCurves/Anim_ScalableColor"));
	if (Curvy3.Object != NULL) {
		AnimScalableColor = Curvy3.Object;
	}
	else {
		UE_LOG(LogTemp, Warning, TEXT("Null"));
	}
	TScaleTransition.AddInterpFloat(AnimScalableColor, progressFunction, FName("ScalableColor"), FName("ScalableColor"));
	static ConstructorHelpers::FObjectFinder<UCurveFloat> Curvy2(TEXT("/Game/_Rescale/_Blueprints/AnimationCurves/Anim_CubeAutoSiwtch"));
	if (Curvy2.Object != NULL) {
		SwitchAutoAlpha = Curvy2.Object;
	}
	else {
		UE_LOG(LogTemp, Warning, TEXT("Null"));
	}
	TScaleTransition.AddInterpFloat(SwitchAutoAlpha, progressFunction, FName("AutoAlpha"), FName("AutoAlpha"));
	TScaleTransition.SetTimelineFinishedFunc(SizeChangeEnd);

And here is the function i’m using for my Timeline:


void AScalableGeometry::UpdateSize(float InteracAlpha, float ScalableColor, float AutoAlpha)
{
	
	/*if (ScalableColor == 1) {
		ColorAlphaReachedOne = true;
	}*/
	if (isAuto) {
		CurrentScale = FMath::Lerp(ScaleLevels[SavedScaleIndex], ScaleLevels[TargetScaleIndex], InteracAlpha);
	}
	else {
		CurrentScale = FMath::Lerp(ScaleLevels[SavedScaleIndex], ScaleLevels[TargetScaleIndex], InteracAlpha);
	}
	SetActorScale3D(FVector(CurrentScale));
	if (CheckCollide() || CollidedDuringRescale) {
		CollidedDuringRescale = true;
	}
	Color(ScalableColor);
}

If you have any idea, thanks in advance

I’ve finally find a way to do it. Just retrieve the different curves in the constructor, use the getfloatvalue function with the getplaybackposition of the timeline to get a correct value.