Timelines only run once for each time they are called. With the timeline being called within BeginPlay, that means that it will only trigger at the start of the level that is being loaded. You would have to call it from another event that can be re-triggered if you want the timeline to repeat.
Hi ,
Yes the timeline runs once. But what i want it that as long as the timeline is running, it should call some function or set some value. I would expect, that EffectProgress gets called each tick, as long as the timeline is running and this doesn’t happen.
A timeline is used to spread out an event over the length of the timeline (think a drawbridge going up) rather than continuously preforming that event while the timeline is playing. To get the behavior you’re looking for, however, it may be possible to set a boolian to true at the start of the timeline (and reset to false at the end), then use the event Tick to check the boolian and call your EffectProgress method.
/************************************************************************/
/* TIMELINE */
/************************************************************************/
/** Timeline for the effectprogress*/
FTimeline TimeLine;
/** Deltatime(stepsize) for the timer calling the timeline tick */
static const float DELTATIME;
/** Function which gets called from the Timer to call EffectProgress */
void TickTimeline();
/** Function which gets called from the Timeline on a Tick */
UFUNCTION()
void EffectProgress(float Value);
Effect.cpp:
Constructor:
const ConstructorHelpers::FObjectFinder<UCurveFloat> Curve(TEXT("CurveFloat'/Game/OwnStuff/EffectCurve.EffectCurve'"));
TimeLine = FTimeline{};
FOnTimelineFloat progressFunction{};
progressFunction.BindUFunction(this, "EffectProgress"); // The function EffectProgress gets called
TimeLine.AddInterpFloat(Curve.Object, progressFunction, FName{TEXT("EFFECTFADE")});
/** The function which gets called from the timeline tick */
void AEffectBallSpeed::EffectProgress(float Value)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT(“EffectProgress: timeline: %f value:%f”), TimeLine.GetPlaybackPosition(), Value));
// do something
}
Called Function from Timer
/** Function which gets called from the Timer to call EffectProgress */
void AEffectBallSpeed::TickTimeline()
{
if (TimeLine.IsPlaying())
{
TimeLine.TickTimeline(DELTATIME);
}
else
{
GetWorldTimerManager().ClearTimer(this, &AEffectBallSpeed::TickTimeline);
SetLifeSpan(0);
}
}
I’m trying to transcribe this script for a BPFunction… I Receive error when trying access GetWorldTimerManager() from UBlueprintFunctionLibrary and not found…
I Necessary Create This to Modify parameters why Dynamic Curves Floats… various equals curves in Diff Seconds…
GetWorldTimerManager is a function defined in the Actor class. Including Actor.h in the source file that accesses GetWorldTimerManager should allow it to be recognized.
This is still Nr1 on Google for c++ timelines and this answer is a bit misleading for using tick of the actor for the timeline. The timeline component itself has already a tick which can be used for this I think. I wrote an answer with a code example here:
I write this here, but is EXTREMELY IMPORTANT that the HandleFunction that you bind to the FOnTimelineFloat isa UFUNCTION, if it isn’t UE4 won’t pick it up and it will never trigger. Probably because it needs the reflection given by UFUNCTION to find the method