To learn more about the engine, I have been trying to recreate in code the fireball actor from the FeaturesTour2014.
You can find a quick example of the actor in this video (~4min): https://youtu.be/MkhHix5g1m0?t=249
For the last 3 days, I have been struggling on how to implement the timeline used in the blueprint.
Here is the timeline in the BP:
And here is the float curve contained in the timeline:
Here is the corresponding code I came up with.
Inside the code of my fireball actor, I create a curve object based on the curve file.
static ConstructorHelpers::FObjectFinder<UCurveFloat> CurveTest(TEXT("CurveFloat'/Game/Scale.Scale'"));
Curve = CurveTest.Object;
Then I create the test timeline and attach it an event for the update, an event for the end, and an event to the curve update. Each function consists of a simple log print.
FTimeline test;
test.SetTimelineLength(1);
FOnTimelineEvent testEvent = FOnTimelineEvent();
testEvent.BindDynamic(this, &AFireBall::OnEventEvent);
FOnTimelineEvent testEvent2 = FOnTimelineEvent();
testEvent2.BindDynamic(this, &AFireBall::OnEventEvent2);
FOnTimelineFloat testEvent3 = FOnTimelineFloat();
testEvent3.BindUFunction(this, "ProgessTimeLine");
test.AddInterpFloat(Curve, testEvent3, FName("Percentage_Complete"));
test.SetTimelineFinishedFunc(testEvent);
test.SetTimelinePostUpdateFunc(testEvent2);
UE_LOG(FantasiaInit, Log, TEXT("Start test."));
test.PlayFromStart();
Now here is the result:
FantasiaInit: Start test.
FantasiaInit: ProgessTimeLine 1.000000
FantasiaInit: OnEventEvent2
But if I run the timeline used in the example fireball blueprint, the update function is being called dozens of times.
Do you have any idea on what is the difference?