How Expose Float From My TimeLine C++ in BluePrint Tick, is possible?

Hi,
I created a copy of the topic BindFunction Timeline and is working perfectly …

Now, I Create My TimeLine with dynamic curves and like to know how can I make my function to return the current value that is running in the Timeline for an output variable … Same as TimeLine in BluePrint …

This is my TimeLine Function…

float ATimeLineExecute::VJTimeLine_Execute()
{
	TimeLine = FTimeline{};

    // Create Dynamic Custom Curve
	FRichCurve xEditCurve = *new FRichCurve;
	FKeyHandle KeyHandle = xEditCurve.AddKey(10.f, 1000.f);
	UCurveFloat* xCurveFloat = ConstructObject<UCurveFloat>(UCurveFloat::StaticClass());
	FOnTimelineFloat progressFunction{};

	xEditCurve.AddKey(0.0f, 0.0f, true, KeyHandle);
	xEditCurve.AddKey(5.f, 1000.f, false, KeyHandle);
	xEditCurve.AddKey(10.f, 10000.f, false, KeyHandle);

	xCurveFloat->FloatCurve = xEditCurve;

    // Bind Function
	progressFunction.BindUFunction(this, "EffectProgress");

	TimeLine.AddInterpFloat(xCurveFloat, progressFunction, FName{ TEXT("EFFECTFADE") });

        // ------------------------------------------------
        // How I Return Float in Execution???
        // ------------------------------------------------
	return returnFloat;
}

Hi CrashAngel,

Using the return function most likely won’t be what you need, as it will only return the float once the entire timeline has finished. If you would like to access one of the variables while the timeline is in use, then please try using a UPROPERTY for the float that is declared outside of the function, and set to BlueprintReadWrite, VisibleAnywhere or EditAnywhere so that it’s possible to read it in a blueprint. You could then have it be checked using the OnTick event or something similar to have it constantly updating.

Hope this helps!

Have a nice day,

I did as you said and seems to be working when I start the engine …

But after about 30 seconds running visual studio just returning an error

Part My Code Below:

void AVJTimeline::BeginPlay()
{
	Super::BeginPlay();

	bool StartConfig = false;
	bool xTimeLineUpdate = true;
	bool xTimeLineChange = false;

	TimeLine = *new FTimeline;
	TimerHandle = *new FTimerHandle;
	xEditCurve = *new FRichCurve;
	xCurveFloat = ConstructObject<UCurveFloat>(UCurveFloat::StaticClass());

	TimeLine.PlayFromStart();

	GetWorldTimerManager().SetTimer(TimerHandle, this, &AVJTimeline::TickTimeline, DeltaTime, true, 0.0f);
}

void AVJTimeline::VJTimeLine_Execute(){

	if (StartConfig == false){ AVJTimeline::Timeline_Execute_Change(); StartConfig = true; }

	if (xTimeLineUpdate == true && xTimeLineChange == true){

		xTimeLineUpdate = true;
		TimeLine.SetLooping(false);

		FScriptDelegate FinishedEvent;
		FinishedEvent.BindUFunction(this, TEXT("Timeline_Execute_Change"));
		TimeLine.SetTimelineFinishedFunc(FOnTimelineEvent(FinishedEvent));
	}
}

void AVJTimeline::Timeline_Execute_Change(){

	float xTimeLength = CalculateBPMSecondsToBeats(BPM, Beats);

	FOnTimelineFloat ProgressEvent{};
	
	xEditCurve.Reset();

	TimeLine.SetTimelineLengthMode(ETimelineLengthMode::TL_LastKeyFrame);
	TimeLine.SetTimelineLength(CalculateDegree(Degree));
	TimeLine.SetLooping(IsLoop);

	KeyHandle = xEditCurve.AddKey(0.0f, 0.0f);
	KeyHandle = xEditCurve.AddKey((xTimeLength / 2), CalculateDegree(Degree), false, KeyHandle);
	KeyHandle = xEditCurve.AddKey(xTimeLength, 0.0f, false, KeyHandle);
	
	xEditCurve.SetKeyInterpMode(KeyHandle, Curve);

	xCurveFloat->FloatCurve = xEditCurve;

	ProgressEvent.BindUFunction(this, "TimeLine_Update");

	TimeLine.AddInterpFloat(xCurveFloat, ProgressEvent, FName{ TEXT("TimelineProgress") });
	TimeLine.Play();
	
	xTimeLineUpdate = false;
	xTimeLineChange = false;
}

void AVJTimeline::VJTimeLine_Update(float xValue){
	xTimeLineUpdate = true;
	if (xTimeLineChange == true){ xTimeLineChange = false; }
	else{ xTimeLineChange = true; }
}


void AVJTimeline::TickTimeline(){
	if (TimeLine.IsPlaying()){

		if (xTimeLineUpdate == true){
			AVJTimeline::VJTimeLine_Execute();
			xTimeLineUpdate = false;
		}

		TimeLine.TickTimeline(DeltaTime);
	}
	else{
		GetWorldTimerManager().ClearTimer(this, &AVJTimeline::TickTimeline);
		SetLifeSpan(0);
	}
}

According to the error shown in the picture you provided, the issue lies elsewhere in the code. Could you provide me with all of your .cpp and .h files so that I can look at them and find where the issue is? It’ll be easier to diagnose if I can put them into the compiler myself.

VJTimeline.h >> JustPaste.it - Share Text & Images the Easy Way

VJTimeline.cpp >> JustPaste.it - Share Text & Images the Easy Way

The issue is still not contained in these lines of code. The line that the error in your picture is pointing to would be:

TArray<FRichCurveEditInfoConst> Curves = GetCurves();

I need the file (CurveBase.cpp) that this line is in, as well as the file that declares/defines ‘GetCurves();’. It would help if you were to provide me with all of the code files you are using for your project, so that I know what every function that is being called does.

Edit: Ah, this is a function that is part of the engine itself. I apologize. I’ll be investigating this issue and I’ll let you know as soon as I find the problem.

This file is the engine curvebase

C:\UnrealEngine\Engine\Source\Runtime\Engine\Private\CurveBase.cpp - Line 788

http://jpst.it/yQTi

Ok, Thanks Man!

:wink:

This is My Source / Content Project ->> BluePrint And Level…

In BluePrint I Set Keys 1,2,3,4 in Keyboard to Fire Events to Change Values to Test

link text

What were you doing when the crash occurred and what had you changed in the code to be exact? Also what version of the editor are you using? Using your code, I am still unable to reproduce the crash, which is the first step to finding out what is wrong.

Im Using Version 4.7.3

I Start the Editor and Numbers begin to scroll across the screen as if the code was working … after about 30 seconds I get the error Visual studio …

I I did some tests here and when I change the variable xCurveFloat I’m building the curve to a variable that takes a type curve

const ConstructorHelpers :: FObjectFinder <UCurveFloat> Curve (TEXT ("CurveFloat '/ Game / NewCurveBase' '));

some asset in the process engine also works but the error has the visual tudio not happen …

I believe that should be the way of how I’m building the curve in the variable

KeyHandle = xEditCurve.AddKey(0.0f, 0.0f);
     KeyHandle = xEditCurve.AddKey((xTimeLength / 2), CalculateDegree(Degree), false, KeyHandle);
     KeyHandle = xEditCurve.AddKey(xTimeLength, 0.0f, false, KeyHandle);

The version could be causing the issue. I’m currently using 4.8.0 Preview 2 and I cannot get the crash using your code. Can you try updating to the new editor? Be sure to make a copy of your project if you do so, in case it causes more problems. Are you launching the editor through debug in Visual Studio? If so, please try running the Binary version and see if you still experience this crash.

OK I Get Your Version… Yes Launch Debug in Visual Studio…

I Trying Test and before i post results… Thanks …

Hi, Try This…

Create a New Project Name: CrashAngelArts

Open Project

File > Add Class To Project > Class Actor > Name: VJTimeline

Open VisualStudio and Replace VJTimeline.h / VJTimeline.cpp

Open Editor And Create New BluePrint Type: VJTimeline

ScreenShhot > ConstrucScript e EventGraph

My BluePrint And Files Attached in Version 4.8…

[link text][3]

Hi CrashAngel,

I was able to reproduce the crash using the blueprints/files your provided, but I cannot think of an immediate fix or work around for the issue. I have placed a bug report in our system for your crash however. For your reference, the bug number is UE-15512. I hope we can have this fixed for you as soon as possible and I thank you for working with me to reproduce the crash.

Have a nice day

OK, Thanks!