# How to create a Timeline in C++?

**URL:** <https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 13, 2014, 8:29pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029 "2014-10-13T20:29:55Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_482d02a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_482d02a4](https://forums.unrealengine.com/u/anonymous_user_482d02a4)\
**Post date:** [October 13, 2014, 8:29pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/1 "2014-10-13T20:29:55Z")

</div>

Hi,

i’m trying to set up a timeline in c++.

.h:

```
FTimeline TimeLine;
UFUNCTION()
	void EffectProgress(float Value);

```

.cpp:

Constructor:

```
	const ConstructorHelpers::FObjectFinder<UCurveFloat> Curve(TEXT("CurveFloat'/Game/OwnStuff/EffectCurve.EffectCurve'"));
	TimeLine = FTimeline{};
	FOnTimelineFloat progressFunction{};
	progressFunction.BindUFunction(this, "EffectProgress");
	TimeLine.AddInterpFloat(Curve.Object, progressFunction, FName{TEXT("EFFECTFADE")});

```

BeginPlay:

```
	TimeLine.PlayFromStart();

```

The function which should get called from the timeline:

```
    void AEffectBallSpeed::EffectProgress(float Value)
    {
    	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("EFFECT PROGRESS"));
    }

```

The function is called once. How can it be triggered all the time?  
thx 🙂

edit: changed the name of the question to make it more clear and easier to find for others.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [October 13, 2014, 9:27pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/2 "2014-10-13T21:27:06Z")

</div>

Hey oOo.DanBO.oOo-

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.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_482d02a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_482d02a4](https://forums.unrealengine.com/u/anonymous_user_482d02a4)\
**Post date:** [October 14, 2014, 5:58am UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/3 "2014-10-14T05:58:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![valentegamedev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/valentegamedev/32/1068844_2.png) [@valentegamedev](https://forums.unrealengine.com/u/valentegamedev)\
**Post date:** [October 14, 2014, 12:55pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/4 "2014-10-14T12:55:22Z")

</div>

Thats exactly what I want to know too =)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [October 14, 2014, 3:15pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/5 "2014-10-14T15:15:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_482d02a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_482d02a4](https://forums.unrealengine.com/u/anonymous_user_482d02a4)\
**Post date:** [October 14, 2014, 9:21pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/6 "2014-10-14T21:21:10Z")

</div>

This is my actual solution

## Effect.h:

```
/ ************************************************************************ /
/* 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:

- BeginPlay:

- Called Function from Timeline

- Called Function from Timer

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_482d02a4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_482d02a4](https://forums.unrealengine.com/u/anonymous_user_482d02a4)\
**Post date:** [October 14, 2014, 9:25pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/7 "2014-10-14T21:25:01Z")

</div>

Hi ,  
thanks very much 🙂 you brought me on the right track 🙂  
i got it all working now.

is also fine for me to check if im at the end of the Timeline.

Thx for the help 🙂

---

<div class="post-metadata">

**Author:** ![CrashAngel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/crashangel/32/467279_2.png) [@CrashAngel](https://forums.unrealengine.com/u/CrashAngel)\
**Post date:** [May 8, 2015, 1:53am UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/8 "2015-05-08T01:53:00Z")

</div>

Hi,

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…

How I Change this line to found method??

```
GetWorldTimerManager().SetTimer(TimerHandle, xSpotLight, &UVJWorkspace::TickTimeline, DELTATIME, true, 0.0f);

```

 ![41853-bug.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/7/c27776cbfb0b55716bbe4ed73c84725c8fc1fdac.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [May 8, 2015, 1:20pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/9 "2015-05-08T13:20:30Z")

</div>

Hey CrashAngel-

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.

Cheers

---

<div class="post-metadata">

**Author:** ![spaceharry](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@spaceharry](https://forums.unrealengine.com/u/spaceharry)\
**Post date:** [April 5, 2016, 9:57pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/10 "2016-04-05T21:57:24Z")

</div>

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:

> **[Link to timelines doc for c++?](https://forums.unrealengine.com/questions/384597/link-to-timelines-doc-for-c.html)**
>
> Hello everyone! I am just now diving into C++ from blueprints, and I use timelines a lot in blueprints and was wondering if they were in C++, and if so is there a doc I could use?

---

<div class="post-metadata">

**Author:** ![Azarus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Azarus](https://forums.unrealengine.com/u/Azarus)\
**Post date:** [December 10, 2016, 8:40pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/11 "2016-12-10T20:40:59Z")

</div>

And what if you want to use a timeline in an actor component? If i want to use a timeline on an actor then i would use your code 🙂

---

<div class="post-metadata">

**Author:** ![HeavyBullets](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HeavyBullets](https://forums.unrealengine.com/u/HeavyBullets)\
**Post date:** [May 30, 2017, 2:28am UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/12 "2017-05-30T02:28:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Katianie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Katianie](https://forums.unrealengine.com/u/Katianie)\
**Post date:** [January 21, 2018, 9:19pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/13 "2018-01-21T21:19:30Z")

</div>

I followed both this and the other tutorial for Timelines in C++ but I am getting a “Triggered breakpoint” error: [Timeline in C++ triggers breakpoint - Programming & Scripting - Unreal Engine Forums](https://answers.unrealengine.com/questions/749508/timeline-in-c-triggers-breakpoint.html)

---

<div class="post-metadata">

**Author:** ![Katianie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Katianie](https://forums.unrealengine.com/u/Katianie)\
**Post date:** [February 1, 2018, 4:38pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/14 "2018-02-01T16:38:14Z")

</div>

I got it working 😃

I added my edits to the wiki, additional settings needed to be set in BeginPlay() to get it to tick and work correctly.

[https://wiki.unrealengine.com/Timeline\_in\_c%2B%2B#How\_to\_use\_Timeline\_in\_C.2B.2B](https://wiki.unrealengine.com/Timeline_in_c%2B%2B#How_to_use_Timeline_in_C.2B.2B)

---

<div class="post-metadata">

**Author:** ![BenVlodgi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benvlodgi/32/1194567_2.png) [@BenVlodgi](https://forums.unrealengine.com/u/BenVlodgi)\
**Post date:** [October 3, 2022, 5:01pm UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/15 "2022-10-03T17:01:36Z")

</div>

For seekers of the old knowledge, it is here: [Timeline in C++ (archive)](https://web.archive.org/web/20161223202125/https://wiki.unrealengine.com/Timeline_in_c%2B%2B)

Copied from: [SpaceHarry](https://forums.unrealengine.com/u/spaceharry/summary)’s Wiki post, originally sourced from this linked answer.

> [@Link to timelines doc for c++?](https://forums.unrealengine.com/t/link-to-timelines-doc-for-c/349439/7):
>
> # How to use Timeline in c++
> 
> This example maybe gives you an idea about how to use Timelines in c++.
> 
> ##### It was tested on 4.10, but it should also work on other version in a similar way.
> 
> ##### Disclaimer: This wiki combines previous examples from Answerhub and Forum and adds on top of it, that you dont need the actors tick component where u place the timeline.
> 
> ## .h
> 
> > ```auto
> > YourClass(const FObjectInitializer& ObjectInitializer);
> >  
> > UPROPERTY()
> > UTimelineComponent* ScoreTimeline;
> >  
> > UPROPERTY()
> > UCurveFloat* fCurve;
> >  
> > FOnTimelineFloat InterpFunction{};
> >  
> > UFUNCTION()
> > void TimelineFloatReturn(float val);
> > 
> > ```
> 
> ## .cpp
> 
> > ```cpp
> > // Constructor
> > AYourClass::AYourClass(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
> > {
> > static ConstructorHelpers::FObjectFinder<UCurveFloat> Curvy(TEXT("Reference Path to your Float Curve"));
> > if (Curvy.Object)
> > {
> > fCurve = Curvy.Object;
> > }
> > 	
> > ScoreTimeline = ObjectInitializer.CreateDefaultSubobject<UTimelineComponent>(this, TEXT("TimelineScore"));
> > 	
> > //Bind the Callbackfuntion for the float return value
> > InterpFunction.BindUFunction(this, FName{ TEXT("TimelineFloatReturn") });
> > }
> >  
> >  
> > //BeginPlay
> > void AYourClass::BeginPlay()
> > {
> > //Add the float curve to the timeline and connect it to your timelines's interpolation function
> > ScoreTimeline->AddInterpFloat(fCurve, InterpFunction, FName{ TEXT("Floaty") });
> >  
> > // Start your Timeline or PlayFromStart() etc, can be called anywhere in this class
> > ScoreTimeline->Play();
> > }
> >  
> >  
> > //Your Callback Function for the timeline float value
> > void AYourClass::TimelineFloatReturn(float val)
> > {
> > //Your float val from curve returns here
> > }
> > 
> > ```
> 
> If at the same time you would like to get the return value from another float or vector curve in your return function, then just get the playback position of your timeline and and get the corresponding return value from your curve.
> 
> > ```cpp
> > YourOtherFloatCurve->GetFloatValue(ScoreTimeline->GetPlaybackposition());
> > YourOtherVectorCurve->GetVectorValue("");
> > 
> > ```

---

<div class="post-metadata">

**Author:** ![greg700000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@greg700000](https://forums.unrealengine.com/u/greg700000)\
**Post date:** [October 20, 2024, 1:34am UTC](https://forums.unrealengine.com/t/how-to-create-a-timeline-in-c/296029/16 "2024-10-20T01:34:26Z")

</div>

In blueprint timelines you can set tickgroup. Anyone have a good example with setting the tickgroup of the timeline?
