User Tag List

Results 1 to 2 of 2

Thread: Use several curves with one Timeline in C++

  1. #1
    0

    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.
    Name:  Sample.png
Views: 69
Size:  43.9 KB

    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:
    Code:
    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:

    Code:
    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

  2. #2
    0
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •